I want to zip file.txt
and file with spaces.txt
. I need to keep them in one variable. I can concat these string like this:
files="$files \"$newfilename\""
Then I have all the file names in one variable, separated by space and each one covered with quotation marks. "file.txt" "file with spaces.txt"
so I need to zip them now. However If I do:
tar czf output $files
then bash will produce:
tar czf output '"file.txt."' '"file' with 'spaces.txt"'
If I do
tar czf output "$files"
then bash will do:
tar czf output '"file.txt." "file with spaces.txt"'
In first case, bash insert a apostrophe after and before each word, in the second case, tar takes both files as one name. What should I do to produce tar czf "file.txt" "file with spaces.txt"
if I have exactly this string in $files
variable?