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.

1 Answer 1


GNU 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.

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 (man date).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .