Sep 24, 2007 #1 ranjit Technical User Joined Apr 14, 2000 Messages 131 Location GB Does awk have a function to determine the previous day?
Sep 24, 2007 #2 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO 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. http://rootshell.be/~feherke/ Upvote 0 Downvote
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. http://rootshell.be/~feherke/