Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

is there a way to convert month number to name?


2013-10-22 will become Oct 22

I don't have the GNU date and my OS is AIX.

share|improve this question
up vote 2 down vote accepted

if you only need to map a few keys to values , just use an array


## cmdline argument is e.g. "2003-10-22"

### extract day, month and year into separate variables


# an array to look up th month-names
# since month-numbers start with 1, the first element in the array is invalid.
set -A monthnames invalid Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

## perform the lookup

## display "<Month> <DAY>"
echo ${MONTHNAME} ${DAY}
share|improve this answer

With a recent enough version of ksh:

$ printf "%(%a %b %d %Y)T\n" 2013-10-22
Tue Oct 22 2013

(note that it is locale aware, in a Spanish locale for instance, it will output mar oct 22 2013)

share|improve this answer

GNU date:

$ date -d 2013-10-22 '+%b %-d'
Oct 22

OS X and FreeBSD date:

$ date -jf %F 2013-10-22 '+%b %-d'
Oct 22

%b is an abbreviated month name and %B is a full month name.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.