If you are using GNU AWK
then you might use its' Time Functions to check if it does work do
awk 'END{print strftime("%y%m%d")}' emptyfile.txt
which should output current day in YYMMDD
format. If it does then you might get what you want following way:
awk 'BEGIN{today=strftime("%y%m%d");threedago=strftime("%y%m%d",systime()-259200)}END{print today, threedago}' emptyfile.txt
output (as of today)
210809 210806
Explanation: strftime
first argument is time format %y
is year 00...99, %m
is month 01...12, %d
is day 01...31. Second argument is optional, and it is seconds since start of epoch. If skipped current time is used, systime()
return number of seconds since start of epoch, 259200
is 72 hours as seconds.
Example of usage as regexp, let say that I have file.txt
as follows
210807 120
210808 150
210809 100
and want to retrieve content of 2nd column for today, then I can do
awk 'BEGIN{today=strftime("%y%m%d")}$1~today{print $2}' file.txt
getting output (as of today)
100
(tested in gawk 4.2.1)