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
272 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
ID: 12228973
Try this:

IFS="\n"

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

Author Comment

by:rayskelton
ID: 12229393
Thanks, This works good
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Perl Awk Need Help 3 116
ASCII Non-Printable characters/codes and their HTML equivalents 6 113
scoreUp challenge 14 61
Problem to open Excel file 15 128
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

816 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

10 Experts available now in Live!

Get 1:1 Help Now