Operating System - HP-UX
1830614 Members
2376 Online
110015 Solutions
New Discussion

date showing "0" from 1 to 9 (01-09)

 
SOLVED
Go to solution
Manuales
Super Advisor

date showing "0" from 1 to 9 (01-09)

Hi ... sory .. .and now .. how can i do to see file with next sintax:

i want see Jun 02 instead of Jun (space)2

Thanks .
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor
Solution

Re: date showing "0" from 1 to 9 (01-09)

Hi Manuales:

As I noted, yesterday:

# date '+%b %e'

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: date showing "0" from 1 to 9 (01-09)

Hi Manuales:

As I noted, yesterday:

# date '+%b %e'

...gives space-filled days (and):

# date '+%b %d'

...gives zero-filled days.

Regards!

...JRF...
OldSchool
Honored Contributor

Re: date showing "0" from 1 to 9 (01-09)

Just to be sure I understand, you want the output of "ls -l" to show as "Jun 02" instead of the "Jun 2".

There are no options in the "ls" command that will allow for this.

Are you storing this in a variable, grep'ing for it, or ?

Can't really help without some additional info?

Perhaps you could describe what it is you want your script to accomplish? Lots of different ways to get the same thing done in the unix world, and somebody has probably already written something close that they would be willing to share.

H.Merijn Brand (procura
Honored Contributor

Re: date showing "0" from 1 to 9 (01-09)

GNU ls (from coreutils) does exactly as you want:

--time-style=STYLE with -l, show times using style STYLE:
full-iso, long-iso, iso, locale, +FORMAT.
FORMAT is interpreted like `date'; if FORMAT is
FORMAT1FORMAT2, FORMAT1 applies to
non-recent files and FORMAT2 to recent files;
if STYLE is prefixed with `posix-', STYLE
takes effect only outside the POSIX locale

lt09:/tmp 111 > ls -l --time-style=+'%Y %b %e' te*
-rw-rw-rw- 1 merijn users 107 2006 Jan 29 test.c
-rwxr-xr-x 1 merijn users 192 2006 May 2 test.pl
-rwxr-xr-x 1 merijn users 332 2005 Nov 8 test.sh
lt09:/tmp 112 > ls -l --time-style=+'%Y %b %d' te*
-rw-rw-rw- 1 merijn users 107 2006 Jan 29 test.c
-rwxr-xr-x 1 merijn users 192 2006 May 02 test.pl
-rwxr-xr-x 1 merijn users 332 2005 Nov 08 test.sh
lt09:/tmp 113 >

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
TKeller
Frequent Advisor

Re: date showing "0" from 1 to 9 (01-09)

You could do an ls listing with 1-9 dates showing up as 01-09 with a rather weird-looking ls alias "script" that employs the binary ls and hacks it apart with awk. Problem with that, formatting's rather interesting.
It is said you should treat your body like a temple. I treat mine like an amusement park.