Saturday, October 6, 2007

How to read leading spaces from a file in UNIX?

How do you retain leading spaces while reading from a file in UNIX? One way to do this is change the variable used to set the Internal Field Separator (IFS) in UNIX and set it to nothing.

ORIGINAL_IFS=$IFS
IFS=
while read LINE
do
...
...
...

done < $IN_FILE

IFS=$ORIGINAL_IFS

No comments:

A TRIP TO BHANDUP PUMPING STATION - the birdwatchers paradise

"A Picture from Bhandup Pumping Station" I am a nature lover, and I often like to go birdwatching with my dad. We had read that ...