/ Published in: Bash
Expand |
Embed | Plain Text
for i in $(cat example.txt); do echo $i; done for i (`cat example.txt`) echo $i # (Zsh only)
Comments
Subscribe to comments
You need to login to post a comment.
miklophone on 09/02/06
3 people have marked this snippet as a favorite
for i in $(cat example.txt); do echo $i; done for i (`cat example.txt`) echo $i # (Zsh only)
Subscribe to comments
You need to login to post a comment.
In BASH, this is problematic when the line has text delimited by white space. Example: root@casc-tds-nas:~# cat /tmp/test first second third fourth root@casc-tds-nas:~# for i in $(cat /tmp/test); do echo "line: $i"; done line: first line: second line: third line: fourth