The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 12-02-2009
Registered User
 

Join Date: Jun 2006
Posts: 468
Quote:
Originally Posted by sushmab82 View Post
Hi,
I need last record(last row value) of column 16. Suppose column 16 has 2 records(2 rows) I want to grep and store 2nd record of column16 i.e 3 in my input file.
Ok, if you need column 16 only, use:


Code:
awk -F\; '{print $16}' input
cut -d\; -f16 <input

If you need last column 16, use:


Code:
awk -F\; '{print $16}' input |tail -1
cut -d\; -f16 <input |tail -1
awk -F\; 'END {print $16}' input


Last edited by rdcwayx; 12-03-2009 at 01:51 AM..
  #9 (permalink)  
Old 12-02-2009
ahmad.diab's Avatar
Registered User
 

Join Date: May 2008
Location: Amman Jordan in MEA
Posts: 416
If you mean to store column 16 of all records in an array use below:-

code:-


Code:
gawk -F";" '{a[16]=a[16]";"$16 ; next}
END{for (i in a) {print i,a[i]} }
' file.txt

  #10 (permalink)  
Old 12-03-2009
Registered User
 

Join Date: Nov 2009
Posts: 8
This is what I exactly wanted, Thanks RDC and ahmad for your useful timely reply.
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
File mgt: Do you know the command line command linux_lou Shell Programming and Scripting 4 06-24-2009 06:08 AM
Command that creates file and also greps that file? Sepia UNIX for Dummies Questions & Answers 2 06-18-2009 01:09 PM
cp && rm command, rm: <file> not removed. No such file or directory Leion Shell Programming and Scripting 5 01-19-2009 11:46 PM
awk/sed Command : Parse parameter file / send the lines to the ksh export command rajan_san Shell Programming and Scripting 4 11-06-2008 01:29 PM
End of file using more command Enda Martin UNIX for Dummies Questions & Answers 3 06-18-2001 11:49 AM



All times are GMT -4. The time now is 01:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0