How can we add condition for Date Comparison in AWK

66 views Asked by At

I am giving below command to

hdfs dfs -ls "+hdfsdir" | awk '{$6 == '2022-03-07' ; {print $8}'

$6 contains date in format 2022-03-07.

But when I am executing this query it is giving results for all other dates as well.

Am I doing anything wrong, or is there any other way for passing date in awk?

1

There are 1 answers

15
The fourth bird On

You can use double quotes to match the date, remove the opening curly and remove ; or else it will just print field nr 8 as a separate statement.

awk '$6 == "2022-03-07" {print $8}'