1832903 Members
2898 Online
110048 Solutions
New Discussion

Help on ls -l Command

 
abhay kumar_1
New Member

Help on ls -l Command

For files older than 1 year, the ls -l command shows modification date/time as year and month only.

How can I get the last modification date/time in YYYY MM DD HH:MI:SS format for files older than 1 year when running LS -L command.



8 REPLIES 8
Uday_S_Ankolekar
Honored Contributor

Re: Help on ls -l Command

Try ls -altr (reverse order.

or ls -alt

-USA..

Good Luck..
James R. Ferguson
Acclaimed Contributor

Re: Help on ls -l Command

Hi:

Standard Unix. However, you can get a "super ls" from here:

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

Regards!

...JRF...
Helen French
Honored Contributor

Re: Help on ls -l Command

Hi abhay,

Try this:

# ls -acl

This will list the time of last modification of the inode (file creation, mode changes etc)

HTH,
Shiju
Life is a promise, fulfill it!
Christopher McCray_1
Honored Contributor

Re: Help on ls -l Command

I don't think there is a way because for files that havent been accessed in that long, the month/day/year format is all hpux cares about.

Perhaps the gurus out there may come up with something more magical for you.

Good luck,
Chris
It wasn't me!!!!
abhay kumar_1
New Member

Re: Help on ls -l Command

The key here is that the file is older than one year.

For clarification purposes, try this :

1. Create a file with modification date and time of Jan 2, 2001 12:35 PM.

touch -m 0101123502 new

2. LS -L output is shown below :

0 Jan 1 12:35 new

3. Now change the modification date/time to Jan 1, 2001 12:35

touch -m 0101123501 new

4. Now try the LS -LTRA command.

0 Jan 1 2001 new

Notice that hour/minute information is missing.


Frank Slootweg
Honored Contributor

Re: Help on ls -l Command

Kind of a hack and rather slow, especially for large file, but UNIX standard:

$ ll /usr/conf/lib/libspt.a
-r--r--r-- 1 bin bin 63556 Oct 30 1997 /usr/conf/lib/libspt.a
$ echo /usr/conf/lib/libspt.a | cpio -o 2>/dev/null | cpio -ivt 2>/dev/null
100444 bin 63556 Oct 30 23:50:34 1997 /usr/conf/lib/libspt.a
$
Steve Steel
Honored Contributor

Re: Help on ls -l Command

Hi


Another hack but easy

tar -cf - dtksh.examples/|tar -tVf -

Gives user no and gid which is only disadvantage


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Steve Steel
Honored Contributor

Re: Help on ls -l Command

Hi

here is a pointer


find $1 -mtime +365|while read line
do
if [ -d $line ]
then
echo " "
echo $(ll -d $line)
else
echo $(ll $line|cut -c1-32) $(tar -cf - $line|tar -tVpf -|cut -c 17-128)
fi
done


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)