Link to home
Start Free TrialLog in
Avatar of rayskelton
rayskelton

asked on

ksh - How do I read a file, row by row and not strip off white spaces as 'read' does.

How do I read a file, row by row and not strip off white spaces as 'read' does. I am using the pre 88 version of ksh.

This is my current read of a file which I test conditions and edit records. None of my trailing spaces are read from this line.
 cat $AIXX_MVR_RESULT_FILE | while IFS="\n" read resLine

Below is a line, which reads without trimming the trailing white spaces.
     resLine=$(echo "$line" | cut -c0-$editOffset)

How do I incorporate the above line in a while loop as the cat is doing above.
The snippet below is the bigger example.

###########################################################
# Replace the result file posn/bsn with the previouly
# captured posn/bsn for AIXX Result
#########################################################
            cat $AIXX_MVR_RESULT_FILE | while read resLine
              do
               aixxRecType=$(echo $resLine | cut -c0-2)
               if [ $aixxRecType == "04" ]; then
                 print "04 Record type found:"$aixxRecType
                 # Substitute posn/bsn
                 typeset substitutionLength=29
           
                 returnedSubString=" "
           print "RESLINE befory function:"$resLine
                 SubStringFunc1 $resLine $QUOTEBACK 5 $substitutionLength
                fi
            resLine=$(printf "%-80s" $resLine)
            print $resLine >>$RESULT_HOME/$UNQ_AIDS_RESULT.aidsMvr
            resLine=" "
              done

 
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rayskelton
rayskelton

ASKER

Thanks, This works good