I have an array of files (some have spaces). I use genisoimage to create an iso file from these files, but the spaces mess it up.
Here's an example:
#This is my array of files. Note: "2 a" is a filename with a space in it. files=(1 "2 a" 3) #Here I try to create an iso file with the files in the array..fail echo "${files[@]}"|xargs genisoimage -o "test.iso"
I get this output:
genisoimage: No such file or directory. Invalid node - '2'.
If I just look at the output of echo "${files[@]}
, I see that the output of files is not properly quoting the filenames (thus 2 a
becomes 2
)
Is there a way to output an array of files that will be properly escaped for use by xargs? I'd prefer a way to just output the element separator as a null character so I can use the -0
option in xargs.