How do I pass each line from a text file as an argument to a script I have written? So each line is then in itself a sin开发者_运维问答gle arg to the script each time.
cat file | xargs --replace script {}
I should note that if you want each line of the file to be treated as one argument to your script, add quotes as appropriate to the {}, most likely \"{}\"
No need for cat
xargs -I {} --arg-file input-file script_file {}
you can do this
while read -r line
do
./script_i_have_written.sh "$line"
done <"file"
but why do that when in your "script_i_have_written.sh", you can parse the text file straight away
#!/bin/bash
# script_i_have_written.sh
while read -r line
do
echo "do something with $line"
done <"file"
精彩评论