1754321 Members
2755 Online
108813 Solutions
New Discussion юеВ

Re: ls options

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: ls options

>ls -lrt *ABC, it will give a listing according to timestamp.

>But from other directories if i give
ls -lrt /temp/*ABC,
the output differs than the above.

Different how? I just see the full path vs just the filename:
Dec 14 2005 threadinit.o
Dec 14 2005 /var/tmp/threadinit.o
Rinky
Advisor

Re: ls options

Yes,

ls -rt will give the right output only till the minutes.
i.e if the files are all created in one minute, with few seconds gap, ls will give the output in alphabetical order.

Is there any way to get the order right, keeping in mind the seconds of creation also?
Dennis Handly
Acclaimed Contributor

Re: ls options

>ls -rt will give the right output only till the minutes.

Since ls(1) has the timestamp in seconds, you have to assume it sorts based on that. Not minutes then alpha.

>Is there any way to get the order right, keeping in mind the seconds

This is done.
$ touch -t 200706210200.01 aa
$ touch -t 200706210200.09 zz
$ ll -t -og
-rw-rw-r-- 0 Jun 21 02:00 zz
-rw-rw-r-- 0 Jun 21 02:00 aa
$ ll -rt -og
-rw-rw-r-- 0 Jun 21 02:00 aa
-rw-rw-r-- 0 Jun 21 02:00 zz

 

You can also change the ls output format by looking at these posts:

http://h30499.www3.hp.com/t5/tag/ls.cat/tg-p