I have text file, each line containing a string:
input.txt:
This is Line 1
This is Line 2
I want to pass each line as an argument to another script, like so:
consume.sh -n "This is Line 1" -n "This is Line 2"
So what I did was create a script to do this:
file_parser.sh:
IFS=$'\n'
MY_ARGS=
for p in `cat input.txt`
do
MY_ARGS="${MY_ARGS} -n \"$p\""
done
bash consume.sh $MY_ARGS
It looks like bash is putting quotes around the WHOLE arg, like so:
consume.sh '-n "This is Line 1" -n "This is Line 2"'
How can I construct a string of args to be passed to another script?