![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Cut the last field | 435 Gavea | Shell Programming and Scripting | 9 | 03-17-2009 01:04 PM |
| Moving Part of a field to another field using AWK | rjsha1 | Shell Programming and Scripting | 5 | 08-04-2006 05:39 AM |
| add increment field when first field changes | azekry | Shell Programming and Scripting | 2 | 11-14-2005 04:21 PM |
| TTL field??? | solvman | UNIX for Advanced & Expert Users | 11 | 10-12-2001 12:54 AM |
| awk sub-field? | kristy | UNIX for Dummies Questions & Answers | 2 | 10-05-2001 04:07 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
Code:
awk ' { for ( i=1;i<8;i++ ){ $i=""}$0=$0;print }' "file"
|
| Sponsored Links | ||
|
|