Operating System - HP-UX
1753971 Members
8713 Online
108811 Solutions
New Discussion юеВ

Re: ll and obtaining date and timestamps

 
SOLVED
Go to solution
KPS
Super Advisor

ll and obtaining date and timestamps

I'm trying to figure out if there is a certain switch that I can use with ll to be able to see the date and timestamp of files that are older than 1 year? As far as I see, ll only shows me the date and year for files older than a year. Any files older than less than a year are listed with date and time. I just had a look through the man page and I'm not seeing any specific switches that I can use to get this specific view in the listing that I'm looking for.

Again what I'm trying to do is use ll to show tme date and time of files older than a year.
Any help would be greatly appreciated!

Thanks,
KPS
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor
Solution

Re: ll and obtaining date and timestamps

Hi KPS:

This is the normal behavior of 'ls'. However, using a small Perl snippet:

# perl -MPOSIX -le '@ARGV=glob("*") unless @ARGV;for (@ARGV) {print join " ",strftime("%m/%d/%Y %H:%M",localtime((stat $_)[9])),$_}'

Simply 'cd' to the directory you want to examine, or run the above with an argument like:

/etc/*

This isn't recursinve, but acts like a simple 'ls -l'.

Regards!

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

Re: ll and obtaining date and timestamps

Hi (again):

If you want a recursive list (as with 'find'), this is quick:

# perl -MPOSIX -MFile::Find -le '@ARGV=(".") unless @ARGV;find(sub{print join " ",strftime("%m/%d/%Y %H:%M",localtime((stat $_)[9])),$File::Find::name},@ARGV)' /path

...either pass the '/path' you want to examine as the argument, or omit it and your current directory will be examined.

Regards!

...JRF...
KPS
Super Advisor

Re: ll and obtaining date and timestamps

Thanks James, if this is normal behavior and no workaround to it within ll, then I think that's the answer I was after. I appreciate the workaround, but I was trying to keep it within the ll or ls -l command.

I appreciate your help....

/KPS
KPS
Super Advisor

Re: ll and obtaining date and timestamps

.
James R. Ferguson
Acclaimed Contributor

Re: ll and obtaining date and timestamps

Hi (again):

Very well, then see (also) my post from the other day with an 'ls' kludge I once found (somewhere) in the ITRC:

http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1225117

...JRF...
CharlesC
Advisor

Re: ll and obtaining date and timestamps

This is a simple trick for this situation:

# ll | awk 'match(length($8),4)'
What if...