This is how you iterate thru a text file outputting a line at a time in Bash shell scripting.
IFS='\n'; for i in(cat FILE.TXT); do echo "$i"; done
Byte sized tech know-how.
This is how you iterate thru a text file outputting a line at a time in Bash shell scripting.
IFS='\n'; for i in(cat FILE.TXT); do echo "$i"; done
Copyright © 2024 Txt
Actually, this is how not to do it — it starts a useless cat process and needs to store the whole file in memory. The right way to do it goes like this:
while read line
do
echo $line
done < FILE.TXT
to iterate file lines is a a bad idea. Plus, the expansion aspect mentioned by @mklement0 (even though that probably can be circumvented by bringing in escaped quotes, which again makes things more complex and less readable). Egor Hans Nov 12 ’17 at 14:23
If you want the text file line by line including blank lines and terminating lines without CR, you must use a while loop and you must have an alternate test for the final line.