BASH: Reading Text File
BASH for C programmers:
Read a text file word-by-word in BASH:
Read a text file word-by-word in BASH:
#!/bin/bash for WORD in `cat filename` do echo $WORD doneRead a text file line-by-line in BASH:
#!/bin/bash while read LINE do echo $LINE done < filenameLooping in BASH:
i=0 while [ $i -lt 10 ] do echo $i # next i=$(($i+1)) doneUpdate: another way to loop suggested in the comment.
Comments
for (( i = 1; i <= 10; i++ )); do echo $i ; done