Solved

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

Posted on 2004-10-05
2
268 Views
Last Modified: 2013-12-26
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

 
0
Comment
Question by:rayskelton
2 Comments
 
LVL 20

Accepted Solution

by:
dsacker earned 250 total points
Comment Utility
Try this:

IFS="\n"

cat "$1" | while read line; do
    echo "Line = $line"
done
0
 

Author Comment

by:rayskelton
Comment Utility
Thanks, This works good
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now