0

I have my array of arguments "$@" that I would like to reuse in an other process.

Basically what I want is a way to say :

string="$(save_array "$@")"
# save string to a file

And in another process:

# load string from file
arr="$(load_array "$string")"

All solutions I found on stackoverflow seemed to lose some information (eg would not work if some of the items in the array contain newlines or \0 character.

It is OK if the solution uses well known programs (grep/sed/python), but not something not installed on a base system.

2
  • Can array elements actually contain \0 in bash? That would surprise me. Commented Oct 3, 2017 at 6:18
  • Yes, it also seems from my tests that it is not possible to have \0 in arrays. It seems that the second proposition in stackoverflow.com/a/18860477/1993501 works for me Commented Oct 3, 2017 at 6:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.