Reputation: 95
I have tool that merges multiple files to one:
totool=""test file1.gam" "test file2.gam" "test fileN.gam""
tool $totool outfile.wrl
Problem is that tool recognise space as file delimiter and "test file1.gam" will be treated as two files. When I try do double quote variable argument:
tool "$totool" outfile.wrl
program try to open single file "test file1.gam test file2.gam test fileN.gam" instead of multiple files.
I try to escape double quotes around each file name:
totool=""\"test file1.gam\"" "\"test file2.gam\"" "\"test fileN.gam\"""
but program recognise escaped double quotes as part of file name: Unable to open file '"test file1.gam" "test file2.gam" "test fileN.gam"' for reading
Number of .gam files is variable and $totool is defined in loop.
Any suggestions?
Upvotes: 4
Views: 293
Reputation: 212374
Using an array is certainly reasonable. Your attempts to quote can be addressed with eval
and a single quote (escaping within double quotes will work as well, but using a single quote is much cleaner):
totool='"test file1.gam" "test file2.gam" "test fileN.gam"'
eval tool $totool outfile.wrl
Upvotes: 1