Skip to main content
The 2024 Developer Survey results are live! See the results
added 5 characters in body
Source Link
Stéphane Chazelas
  • 553.7k
  • 92
  • 1.1k
  • 1.6k

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)

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) awk '
  BEGIN{today = toupper(ENVIRON["TODAY"])}
  index($0, today) && $NF != 0
  ' /u01/app/server1/listener_scan/trace/listener_scan.log

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)

added 5 characters in body
Source Link
Gilles Quénot
  • 34.2k
  • 7
  • 69
  • 88

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) awk '
  BEGIN{today = toupper(ENVIRON["TODAY"])}
  index($0, today) && $NF != 0
  ' /u01/app/server1/listener_scan/trace/listener_scan.log

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 +%d-%b-%Y) awk '
  BEGIN{today = toupper(ENVIRON["TODAY"])}
  index($0, today) && $NF != 0
  ' /u01/app/server1/listener_scan/trace/listener_scan.log

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) awk '
  BEGIN{today = toupper(ENVIRON["TODAY"])}
  index($0, today) && $NF != 0
  ' /u01/app/server1/listener_scan/trace/listener_scan.log
Source Link
Stéphane Chazelas
  • 553.7k
  • 92
  • 1.1k
  • 1.6k

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 +%d-%b-%Y) awk '
  BEGIN{today = toupper(ENVIRON["TODAY"])}
  index($0, today) && $NF != 0
  ' /u01/app/server1/listener_scan/trace/listener_scan.log