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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

math in awk (or something?!?!)

Status
Not open for further replies.

WiccaChic

Technical User
Joined
Jan 21, 2004
Messages
179
Location
US
Hi all. I am using the following to get the starting line number of some info in a log:

date +"%a %b %e"|xargs -i grep -n {} /u/informix/online.log|tail -n 1|cut -f 1 -d :|xargs -i more -p {} /u/informix/online.log

I want to take the resulting number and subtract it from the total number of lines in the log so I can tail -n just what I want to see. How can I do the math part? I thought the following would work, but I guess I just do not understand awk well enough:

date +"%a %b %e"|xargs -i grep -n {} /u/informix/online.log|tail -n 1|cut -f 1 -d :|xargs -i more -p {} /u/informix/online.log|awk "\99999 - $1"

If my approach is way off, I am open to suggestions. I need to be able to do this from a command line though, not with a script.
 
hi,
not sure whether I understood what you are trying to do.
But I think it is this:
You want to see the last block of lines in your file.
You know how to find the line number of the starting line.
You know that you can use tail command.
I think you need not compute length of this block.
tail +n should do the trick.
hth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top