I have a variable in bash, which is something like
filenames='file 1
file 2
file 3'
I need to send each line in the above variable's content as a single argument to a program. But I can't get bash to that. Here's what I tried:
python -c 'import sys; print sys.argv' $filenames
['-c', 'file', '1', 'file', '2', 'file', '3']
or
python -c 'import sys; print sys.argv' "$filenames"
['-c', 'file 1\nfile 2\nfile 3']
What I'm expecting is something like this
['-c', 'file 1', 'file 2', 'file 3']
I've tried fiddling with the IFS setting too, but couldn't get it right. Any ideas on this?