I am writing a shell-script on an Ubuntu 12.04 server that should compare some data in a log file. In the log file, the date is indicated in the format:
[Mon Apr 08 15:02:54 2013]
As you can see, it indicates Apr.
According to the man page, the parameter that will be used in bash for this, b or h .
However, it does not matter, for me (when comparing the script or directly in the shell) use b , h or B. They all return the full name of the month.
date +"%b"
It is of course very difficult to make comparisons based on the date ...
Has anyone else experienced this and found a solution?
(I'm not sure if this is relevant, but I chose the Norwegian language for installation when I installed the server.)
Thank you answer from @ toro2k here, I ended up with a working solution:
DATE=`LC_ALL=C date +%b" "%d" "%H`
(This did not work:
LC_ALL=C
DATE = date +%b" "%d" "%H
)
source share