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!

How do I find last record

Status
Not open for further replies.

Tison

Programmer
May 12, 1999
216
CH
Does anyone have a little script for me that will find the last record in a file containing duplicates ?
I have a log file with many similar lines of data (only the date time changes) and I want to find the last occurance of a specific string
eg grep "string_value" log_file | (get last entry)
 
Hi Tison !

How about using "tail -1" , this would give u the last line from the file ; maybe u can use "sort" with options to sort on a particular field and then pipe it to tail -1 , this would give u the last line. I am sure this is possible in a more efficient way in awk, but i don't remember the syntax,
hope it helps
rajesh rajeshrcmc@hotmail.com
"Better to ask a question once and be thought a fool once, than never to ask and remain a fool forever"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top