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!

Epoch time

Status
Not open for further replies.

Skywalker1957

Technical User
Nov 21, 2008
85
US
Hey! I'm trying to figure out a way of using awk to sort data off of a field that contains Epoch time. I'm trying to look at only the last 24 hours of log files, so I would need to take Epoch time minus 86400 and sort only those timestamps greater than the timestamp from the last 24 hours.

awk ' $1 > 1277400638 '

but how do I get at that number from within awk? I can calculate it and save it to a flat file in /tmp but how do I call it from within awk or if I put it in a variable, how do I call that environment variable from within awk?

Thanks for your help.
 
how do I call that environment variable from within awk
Simply like this:
export yourVariableHere=1277400638
awk '$1>ENVIRON["yourVariableHere"]'

You may also use the command-line variable assignment:
awk -v yourVariableHere=1277400638 '$1>yourVariableHere'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top