Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting last two fields in record

Status
Not open for further replies.

wtrepani

MIS
May 30, 2002
93
US
Hi all,

I am having a problem with awk. I need to get the last two fields of records in a file that are of different lengths. I can get

|awk {'print $NF'} to work for the last one, but need one prior to it also. I have tried things like:

|awk {'print $NF-1'}, etc to no avail. Any info on this would be helpful.

Thanks

Will
 
try: |awk {if(NF >1){ print $(NF-1), $(NF-2);} -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top