Operating System - HP-UX
1830892 Members
2878 Online
110017 Solutions
New Discussion

ls -l and file date format

 
SOLVED
Go to solution
Wessel Baptist
Advisor

ls -l and file date format

Hi,
ls -l(ell) Reports directory listing in long format, giving amongst date and/or time of last modification for each file. If the time of last modification is greater than six months ago the year is substituted for the hour and minute of the modification time.
Is there a way that I can get always the date instead of the time?
logics take you from A to B, imagination takes you anywhere
15 REPLIES 15
James R. Ferguson
Acclaimed Contributor

Re: ls -l and file date format

Hi:

There is a "super ls" utility available at the porting archive that accomodates your request:

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

Regards!

...JRF...
Christopher McCray_1
Honored Contributor

Re: ls -l and file date format

Hello,

As far as I know, no. You will always get the month and day, but the year is only for files older than 6 mos.

Sorry if this didn't give you what you need.

Chris
It wasn't me!!!!
Vicente Sanchez_3
Respected Contributor

Re: ls -l and file date format

Hi,

I think it's not possible.

Regards, Vicente.
H.Merijn Brand (procura
Honored Contributor

Re: ls -l and file date format

Modify to your liking:

a5:/tmp/empty 112 > ls -l
total 18
-rw-rw-rw- 1 probev softwr 55 Mar 4 2002 empty.al
-rw-rw-rw- 1 probev softwr 474 Mar 4 2002 empty.ao
-rw-rw-rw- 1 probev softwr 3103 Mar 4 2002 empty.aq
-rw-rw-rw- 1 probev softwr 42 Mar 4 2002 empty.as
-rw-rw-rw- 1 probev softwr 3066 Mar 4 2002 empty.bk
-rw-rw-rw- 1 probev softwr 6748 Mar 4 2002 empty.fa
-rw-rw-rw- 1 probev softwr 374 Mar 4 2002 makefile
-rw-rw-rw- 1 merijn softwr 0 Dec 9 16:53 xx
a5:/tmp/empty 113 > perl -le'@ARGV or@ARGV=qw(*);for(map{glob$_}@ARGV){chomp($x=localtime((stat$_)[9]));print"$x $_"}'
Mon Mar 4 18:51:16 2002 empty.al
Mon Mar 4 18:32:04 2002 empty.ao
Mon Mar 4 18:51:07 2002 empty.aq
Mon Mar 4 18:24:57 2002 empty.as
Mon Mar 4 18:49:56 2002 empty.bk
Mon Mar 4 18:51:16 2002 empty.fa
Mon Mar 4 18:32:01 2002 makefile
Mon Dec 9 16:53:53 2002 xx
a5:/tmp/empty 114 >

Enjoy, Have FUN! H.Merijn
H.Merijn Brand (procura
Honored Contributor

Re: ls -l and file date format

this is also good: a C source for 'lsi'
Enjoy, Have FUN! H.Merijn
H.Merijn Brand (procura
Honored Contributor

Re: ls -l and file date format

Browser dropped attachment :/
Enjoy, Have FUN! H.Merijn
Wessel Baptist
Advisor

Re: ls -l and file date format

Hi,

first thank you all for your respons.

James,
The ???super ls??? I think is not Year2K compliant. Files created yesterday are reported as made in 1910.

Procura,
The Perl statement as you give to me, doesn???t do anything, but when I add en spave between ???-le??? en the quote (' ) it reports some errors:
bmsd210:root:/tmp> perl -le'@ARGV or@ARGV=qw(*);for(map{glob$_}@ARGV){chomp($x=localtime((stat$_)[9]));print"$x $_"}'
syntax error in file /tmp/perl-ea28386 at line 1, next 2 tokens "@ARGV or"
syntax error in file /tmp/perl-ea28386 at line 1, next 2 tokens "map{"
syntax error in file /tmp/perl-ea28386 at line 1, next token "}"
Execution of /tmp/perl-ea28386 aborted due to compilation errors.
bmsd210:root:/tmp>
But I???m not familiar with perl.
And thanks for the lsi-csript but I don???t have an ANSI C-compiler.

Anyone:
I still have my problem with ls ???l and the report of the filedate.

Regards
Wessel.
logics take you from A to B, imagination takes you anywhere
john korterman
Honored Contributor
Solution

Re: ls -l and file date format

Hi Wessel,
if all other possibilities have been exhausted, try the attached script, using the file whose last modification date you request as par1.
It is slow, but works on my system.

regards,
John K.
it would be nice if you always got a second chance
H.Merijn Brand (procura
Honored Contributor

Re: ls -l and file date format

Maybe you are using an ancient version of perl, because my output was of a real test

# which perl
should not be /usr/contrib/bin/perl
# perl -v
should not be 4.036, but preferably 5.6.1 or 5.8.0

lsi.c should not need an ANSI C compiler. The bundled compiler should be enough

Prebuild HP-UX 11.00 and 10.20 binaries for both perl-5.8.0 and gcc-3.2 (free ANSI C compiler) are available on both my ITRC page https://www.beepz.com/personal/merijn and HP porting centers around the world (http://hpux.connect.org.uk/)
Enjoy, Have FUN! H.Merijn
Jean-Louis Phelix
Honored Contributor

Re: ls -l and file date format

hi,

I don't like very much this 'super ls' but I modified the source to make it work. Just compile it using 'make' and run 'sls -l *'. It should work ...

Regards.
It works for me (© Bill McNAMARA ...)
Wessel Baptist
Advisor

Re: ls -l and file date format

Hi,

John, this is what I was looking for. As you said not fast but it works. Thanks.

Procura,
I couldn???t find perl for hpux10.20.
???make lsi.c??? gives errors and no executable. Sorry.
But John (see above) and Jean-Louis (see below) profided me a working solution. But thanks any way.

Jean-Louis,
Super sl works as I wanted. Tanks.

All,
Many thanks for your respons.

Wessel
logics take you from A to B, imagination takes you anywhere
H.Merijn Brand (procura
Honored Contributor

Re: ls -l and file date format

What errors?

perl-5.8.0 for 10.20 can be found in the download section https://www.beepz.com/personal/merijn/#Downloads rightmost column, links to https://www.beepz.com/personal/merijn/perl-5.8.0-gcc-3.2-10.20-pa11-ora.tbz

lsi now uploaded as https://www.beepz.com/personal/merijn/lsi-pa1.1
Enjoy, Have FUN! H.Merijn
Wessel Baptist
Advisor

Re: ls -l and file date format

 
logics take you from A to B, imagination takes you anywhere
H.Merijn Brand (procura
Honored Contributor

Re: ls -l and file date format

Does your connection support https? (note the s)
I cannot offer you anything else for perl ...

I've put lsi on http://home.hccnet.nl/h.m.brand/lsi-pa1.1
Enjoy, Have FUN! H.Merijn
Wessel Baptist
Advisor

Re: ls -l and file date format

Procura,
If???ve downloaded lsi-pa1.1 and it worked.
Perhaps the problem in contacting www.beepz.com is due to https. I have sometimes problems in contacting secure sites.

Thanks for your help.
logics take you from A to B, imagination takes you anywhere