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

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

let'sLet's say we have below file:

boo,foo,2016-08-30
foo,boo,2016-07-31
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}}'
awk -F, '{if($3>"2015-08-23"){print $0}}'

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

Is there a constant variable in awk, that store today's date? if no, 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.

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.

Tweeted twitter.com/#!/StackUnix/status/636176464199684096
Source Link
Eng7
  • 1.7k
  • 5
  • 18
  • 40

Current date in awk

Is there a constant variable in awk, that store today's date? if no, 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.