1834646 Members
1988 Online
110069 Solutions
New Discussion

Re: ls doubt

 
SOLVED
Go to solution
intp
Frequent Advisor

ls doubt

ls command is not listing the Year part. Only month date and time. how to display year also ?

rw-rw-r-- 1 XYZ mygrp 6648 Dec 14 16:27 dec05.txt

i heard if no year is displayed then its current year...but for above its DEC (last year) and still not showing year part ??

am i missing something ? is there any settings we need to change ?


THANKS


8 REPLIES 8
Mustafa Gulercan
Respected Contributor

Re: ls doubt

hi;
ls -l;
If the time of last modification is greater
than six months ago, or any time in the future, the year is
substituted for the hour and minute of the modification
time.

regards;
mustafa
Torsten.
Acclaimed Contributor

Re: ls doubt

Even DEC is HP now.

But being serious now, this is not a pure ls output. How about the "date"? Perhaps you invoked "ls" with other options (there are really a lot).

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
intp
Frequent Advisor

Re: ls doubt

Thanks.

any option thru which we can see year details also , using ls command even if the file's last modified date is less than 6 months ?
Michael Steele_2
Honored Contributor

Re: ls doubt

Here's a good perl script and more:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=193814
Support Fatherhood - Stop Family Law
James R. Ferguson
Acclaimed Contributor

Re: ls doubt

Hi:

No, the rule is that if the age is older than 6-months, then the year is substituted in lieu of the time.

By definition, this would be 180-days ago or 15,552,000 seconds ago, or just before the current time on December 2, 2005.

Regards!

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

Re: ls doubt

Hi:

If all you want to see is a file's modification ('mtime') timestamp you can do:

# perl -wle 'print scalar localtime ((stat($ARGV[0]))[8])' filename

Regards!

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

Re: ls doubt

Hi (again):

OOPS! Sorry, for a file's 'mfile' that should be:

# # perl -wle 'print scalar localtime ((stat($ARGV[0]))[9])' filename

...the previous post would return the file's 'atime'.

Regards!

...JRF...
H.Merijn Brand (procura
Honored Contributor
Solution

Re: ls doubt

Attached is a perl script that also supports options and recursion.

save as 'lsi' for default behaviour. (sym)link to 'lsm' to get it use the mtime, and to 'lsc' to use ctime, and to 'lsa' to use atime.

options: -a select - and sort by access times
default for lsa
-c select - and sort by change times
default for lsc
-m select - and sort by modification times
default for lsi
-n sort by name default by time
-i sort by inode
-s sort by size
-r reverse default sort order
-f don't sort, print on find
-R recursive search
-t tail, print last 16 entries
-? print help

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn