Operating System - HP-UX
1833758 Members
2330 Online
110063 Solutions
New Discussion

how to change month from Jan ,Feb, to 01,02

 
SOLVED
Go to solution
thebeatlesguru
Regular Advisor

how to change month from Jan ,Feb, to 01,02

in my hpux ,month is show as JAN ~DEC
for example:use command ll-rw-rw-rw- 1 pin pin 10 Jan 16 17:03 zzz
if i wanna change Jan to 01,how can i do it.
hihi
5 REPLIES 5
Michael Tully
Honored Contributor

Re: how to change month from Jan ,Feb, to 01,02

Hi,

By default that is how the output is presented. There is no options within 'ls' itself to change it. You could write a program wrapper that changes the output from the date presented to a number.

Only other thing I can suggest is have a look at 'Super ls'. You can find it at this link.

http://gatekeep.cs.utah.edu/hppd/hpux/Shells/sls-1.0/

HTH
-Michael
Anyone for a Mutiny ?
Deepak Extross
Honored Contributor

Re: how to change month from Jan ,Feb, to 01,02

A little clumsy, but you can put this into a script..
ll | sed "s/Jan/01/g" | sed "s/Feb/02/g"
and so on for all the months.
Steve Steel
Honored Contributor

Re: how to change month from Jan ,Feb, to 01,02

Hi

Put this in a script

exec $1|
sed -e 's/ Jan / 01 /'|
sed -e 's/ Feb / 02 /'|
sed -e 's/ Mar / 03 /'|
sed -e 's/ Apr / 04 /'|
sed -e 's/ May / 05 /'|
sed -e 's/ Jun / 06 /'|
sed -e 's/ Jul / 07 /'|
sed -e 's/ Aug / 08 /'|
sed -e 's/ Sep / 09 /'|
sed -e 's/ Oct / 10 /'|
sed -e 's/ Nov / 11 /'|
sed -e 's/ Dec / 12 /'

Then script command

ex script ll

Output comes with date changed

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Kenny Chau
Trusted Contributor

Re: how to change month from Jan ,Feb, to 01,02

That is the default setting. You can try to write a script to change that but there is no option in the ls command that can do that.

Regards,
Kenny.
Kenny
Peter Kloetgen
Esteemed Contributor
Solution

Re: how to change month from Jan ,Feb, to 01,02

Hi Guru,

try this:

ll | awk -v var=`date +"%e %m %X"` '{print $1, $2, $3, $4, $5, var, $7, $8, $9}'


date +%m gives you the desired format for the month.

You can make a little awk-script which is easier to call then.

Allways stay on the bright side of life!

Peter

I'm learning here as well as helping