How to convert date format from file date format (2017/01/11) to server date format (Thu Jan 12).?
I want to write a script which grep a string for current date ( server date ). first want to convert the date format and to write the grep script.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
date will parse dates in many formats. It will also allow you to output the date in almost any format you want. There is no such thing as "server date format", though.
value='2017/01/11' date --date "$value" 11 Jan 2017 00:00:00 date --date "$value" +'%a %b %d' Wed Jan 11
In your example you seem to want to get from the date in the file to "tomorrow". GNU
date can do that, too:
date --date "$value + 1 day" +'%a %b %d' Thu Jan 12
More information about the formatting options is available in the man page (