Wednesday, 25 February 2015

How to customize the date to get required format in shell programming.

Get name of the day:
date +"%A"

Get only day without month and year:
date +"%d"

Get hour of the day (00..23):
date +"%H"

Get hour of the day (01..12):
date +"%I"

Get day of the year:
date +"%j"

Get name of the month:
date +"%B"

Get only month:
date +"%m"

Get current century:
date +"%C"

Get only year:
date +"%Y"

Get full date in yyyy-mm-dd format:
date +"%F" or date +"%Y-%m-%d"

Get minute of the hour:
date +"%M"

Get second of the minute:
date +"%S"

Get time in hh:mm:ss
date +"%T" or date +"%H:%M:%S"

Get the timestamp:
date +"%s"

No comments:

Post a Comment