You need to match on a pattern such as 06-FEB-2024
, but as was noted in a comment, the date
command returns 06-Feb-2024
.
You can upper-case the variable:
current_date=$(LC_ALL=C date "+%d-%b-%Y")
grep "${current_date^^}" /u01/app/server1/listener_scan/trace/listener_scan.log |
awk '{ if ( $NF != 0 ) print $0 }' >> y.out
Also you can merge the combination:
awk -v date="$(LC_ALL=C date +'%d-%b-%Y')" '$0 ~ toupper(date) && $NF+0'$NF!=0' /u01/app/server1/listener_scan/trace/listener_scan.log >>y.out