May 15, 2011

Read a text file in bash

#!/bin/ksh
# http://mandrivausers.org/index.php?/topic/21998-reading-a-text-file-line-by-line-with-bash/
FILES=./*.txt
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
while read LINE
do
echo $LINE
done < $f

done

No comments:

Cat

Snow Shoe Cat   Bombay Cat   Ragdoll Cat         Persian Cat     Finish Cat