RE: OT-is there a way to do this in unix - date question

You pretty much had it.

Linux
#!bin/sh
echo `date --date=3D$1/12/2005 +%b`

Other Unix OS's
#!bin/sh
echo `date -d=3D$1/12/2005 +%b`

Your script could just ececute this script, however it is probably just =
as easy to make it a function call within the shell script itself that =
needs this information or a direct variable call to the date funtion =
using the original passed variabl or internal variable from your =
program.


-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx =
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Mark W. Farnham
Sent: Friday, February 11, 2005 2:28 PM
To: Oracle-L
Subject: RE: OT-is there a way to do this in unix - date question

#! /bin/sh
#  Copyleft (C) 2005  Rightsizing, Inc.
#
#  mm2mon -- wrapper for date to return 3 char month abbrev from numeric =
arg
#            with not even a hint of error checking.
#
#  Usage:    mm2mon <arg>
#
datedummy=3D`printf 2005%02d01 $1`
/usr/bin/date -d$datedummy +%b

This seems to work. The returns change based on your local language, =
though.
If you have a version of the date command that does not take the -d =
argument this will laugh at you, otherwise it should work fine.

A real shell person may know a cheaper way to format the string than =
invoking printf; that part of my brain is off on tape somewhere. I think =
you have to give the -d option a formatted string and it will figure out =
yymmdd and yyyymmdd. In your case any old yyyy and dd will do.

If you want "like what you get with date +%b" then this is actually what =
you want.
>
> <ganstadba@xxxxxxxxxxx> wrote:
> > without writing a whole series of ifs, given a number 1 - 12 give=20
> > the corresponding three letter month like what you get with date=20
> > +%b, but someone supplies you the digits
> > --
> > http://www.freelists.org/webpage/oracle-l

--
Peter Johnson
Humboldt State University
707-826-6122

--
http://www.freelists.org/webpage/oracle-l


--
http://www.freelists.org/webpage/oracle-l
--
http://www.freelists.org/webpage/oracle-l

Other related posts: