The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-15-2007
jobbyjoseph jobbyjoseph is offline
Registered User
  
 

Join Date: Apr 2006
Location: Mumbai
Posts: 21
Retrieve 5th Field to Last Field !!

I have a script which retrieves certain fields from a text file using awk. The delimiter used is white space.

cat /home/eis/boss/OPS|while read LINE
do
crdno=`echo $LINE | awk '{print $1}'`
atm=`echo $LINE | awk '{print $2}'`
seq=`echo $LINE | awk '{print $3}'`
amount=`echo $LINE | awk '{print $8}'`
rec=`echo "CARD NO:$crdno ATM ID:$atm AMOUNT:$amount SEQ:$seq"`
done
Problem now is that we have a new field added in the text file which has to be retrieved. This field has addresses as values and as such there are white spaces in this field in the addresses. The address field starts at position no. 8 and is the last field as such but due to the white spaces between the values in this field I cannot retrieve the 8th Field without losing out some portion of values due to the white space between them.
eg:
FIELD1 FIELD2 FIELD3 FIELD8
a 21 400 EVERGLADES 20/A
b 22 5000 FLIPSYDE-REGION
c 23 650 GREEN DAY ROCKS

I need to retrieve from the 8th Field to whatever is the last field. Any suggestions on the same ??

Regds,
Jobby