3 ms·
The "convert file into arguments" trick is useful, but a "while read/do" loop would be better: cat file | while read INPUT do command "$INPUT"
by dredmorbius 15y ago
The "convert file into arguments" trick is useful, but a "while read/do" loop would be better:
cat file | while read INPUT
do
command "$INPUT"
done
... which will read the entire line from 'file' into the shell variable "$INPUT", inclusive of whitespace. If you need to do further parsing, of course, you can do that within the loop.
Trap: since you're creating a subshell (at least in bash/Bourne), variables defined within the loop are NOT defined after it exits.