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

Previous day function

Status
Not open for further replies.

ranjit

Technical User
Apr 14, 2000
131
GB
Does awk have a function to determine the previous day?
 
Hi

No, regular [tt]awk[/tt] can not, only [tt]gawk[/tt] has date handling functions :
Code:
print "Today is",strftime("%c",systime())
print "Yesterday was",strftime("%c",systime()-60*60*24)
Your simplest solution would be to ask the [tt]date[/tt] command :
Code:
"date" | getline d; print "Today is",d
"date -d yesterday" | getline d; print "Yesterday was",d
Tested with [tt]gawk[/tt] and GNU [tt]date[/tt].

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top