Skip to main content
2 of 2
Minor formatting, remove duplicate tag
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

Current date in awk

Is there a constant variable in awk, that store today's date? If not, is there a way that can store today's date for daily use?

Let's say we have below file:

boo,foo,2016-08-30
foo,boo,2016-07-31

And I need to compare the date $3 in the file, with today's date, regardless what it is.

i.e below script

awk -F, '{if($3>"2015-08-23"){print $0}}'

where 2015-08-23 will be changed by the current date.

Eng7
  • 1.7k
  • 5
  • 18
  • 40