Source : Mastering Unix Shell Scripting
In this series we learn 12 methods to parse the file in Linux/Unix.
TwelveMethods to Parse a File Line by Line — Part 1
TwelveMethods to Parse a File Line by Line — Part 2
TwelveMethods to Parse a File Line by Line — Part 3
TwelveMethods to Parse a File Line by Line — Part 4
TwelveMethods to Parse a File Line by Line — Part 1
TwelveMethods to Parse a File Line by Line — Part 2
TwelveMethods to Parse a File Line by Line — Part 3
TwelveMethods to Parse a File Line by Line — Part 4
Method
7:
cat $FILENAME | while LINE=$(line)
do
echo "$LINE"
done
cat $FILENAME | while LINE=$(line)
do
echo "$LINE"
done
Method
8:
while LINE=$(line)
do
echo "$LINE"
done < $FILENAME
while LINE=$(line)
do
echo "$LINE"
done < $FILENAME
Method
9:
exec 3<&0
exec 0< $FILENAME
while read LINE
do
echo "$LINE"
:
done
exec 0<&3
exec 3<&0
exec 0< $FILENAME
while read LINE
do
echo "$LINE"
:
done
exec 0<&3
njoy the simplicity.......
Atul Singh