date +%d-%b-%Y
outputs the current date with the day of the month 0-padded to a length of 2, the user's locale month abbreviation, and the year 0-padded to 4 digits.
Depending on who runs that command, you may get something like:
06-فبر-2024
06-лют-2024
06-fév-2024
In the C/POSIX locale, you get:
$ LC_ALL=C date +%d-%b-%Y
06-Feb-2024
It looks like your log contains the same but in uppercase.
Here, you could do:
#! /bin/sh -
TODAY=$(LC_ALL=C date +%d-%b-%Y) exec awk '
BEGIN{today = toupper(ENVIRON["TODAY"])}
index($0, today) && $NF != 0
' /u01/app/server1/listener_scan/trace/listener_scan.log
mawk
, busybox awk
and gawk
can get you that information by themselves, so on a Linux-based systems this is also very likely to work:
#! /bin/sh -
LC_ALL=C exec awk '
BEGIN {today = toupper(strftime("%d-%b-%F"))}
index($0, today) && $NF != 0
' /u01/app/server1/listener_scan/trace/listener_scan.log
(that also affects the way the contents of the log file is decoded into text, but that's likely for the best; that also affects the language of error messages if any)