Operating System - HP-UX
1836574 Members
2468 Online
110102 Solutions
New Discussion

Re: list file creadted year using ll cmd

 
ashanabey
Advisor

list file creadted year using ll cmd

Hi ,

How do I list the files with created year , ll -lrt want give the year.

-rw-r--r-- 1 root sys 10731 Jul 18 23:44 cart.txt
-rw-r--r-- 1 root sys 0 Jul 18 23:44 comp.txt
-rw-r--r-- 1 root sys 773 Jul 18 23:44 devices.txt
-rw-r--r-- 1 root sys 24890 Jul 18 23:44 media.txt
-rw-r--r-- 1 root sys 0 Jul 18 23:44 mtmp.txt
-rw-r--r-- 1 root sys 596 Jul 18 23:44 pools.txt
-rw-r--r-- 1 root sys 351 Jul 18 23:44 stores.txt

Thanks!

Ashan
legend the heart and lend the hand
5 REPLIES 5
Mel Burslan
Honored Contributor

Re: list file creadted year using ll cmd

ls, not ll as you mentioned, on hpux, is not designed to stamp "year" portion of the date to a file unless it is more than one year old. I am not sure what you are after but, if this is a necessity, you can write a script to read the output of ls -l command and output the listing in a way you desire. But there is no option in ls command that will give you the result you want.
________________________________
UNIX because I majored in cryptology...
Tingli
Esteemed Contributor

Re: list file creadted year using ll cmd

I think when the file is older more than 6 months, (or maybe 180 days) it uses year.
James R. Ferguson
Acclaimed Contributor

Re: list file creadted year using ll cmd

Hi Ashan:

The standard UNIX behavior is described in the 'ls' manpages, "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."

You can, however, do something like this:

# ls -alrt|awk -v YEAR=$(date +%Y) '{if ($8~/:/) {$8=YEAR};$NF=$NF;print}'

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: list file creadted year using ll cmd

The original "ls -l" output date-time format
may represent one of the worst "design"
decisions anywhere in UNIX. On the bright
side, GNU "ls" offers more date-time format
options than anyone should want, including
"--time-style=style=+", which can
do nearly anything except send e-mail.

http://www.gnu.org/software/coreutils/manual/
http://www.gnu.org/software/coreutils/manual/html_node/Formatting-file-timestamps.html

I quote:

To avoid certain denial-of-service
attacks, timestamps that would be
longer than 1000 bytes may be treated
as errors.

If that's not scary, what is?
Dennis Handly
Acclaimed Contributor

Re: list file creadted year using ll cmd

>How do I list the files with created year?

You can modify a copy of ls.cat to have your own format:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1320053
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1279941
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1207493
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1182062

>Mel: ls, not ll as you mentioned,

ls(1) and ll(1) are the same executable.

> Tingli: or maybe 180 days

Right, 180 days, or an hour in the future.