Posts

Showing posts from 2007

BASH: Reading Text File

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