1832978 Members
2696 Online
110048 Solutions
New Discussion

Re: command find + sort

 
SOLVED
Go to solution
Jairo Campana
Trusted Contributor

command find + sort

as I can order por date

$ find . -name *.old -exec ls -ltr {} \;|more
-rw-r--r-- 1 named named 351 Aug 3 2001 ./a/a/aaaimar.com.old
-rw-r--r-- 1 named named 360 Jul 12 2001 ./a/a/aaci.org.ar.old
-rw-r--r-- 1 named named 408 Mar 14 2003 ./a/a/aacolombo.com.old
-rw-r--r-- 1 named named 410 Mar 14 2003 ./a/a/aaconcagua.com.old
-rw-r--r-- 1 named named 664 Mar 14 2003 ./a/a/aaehsa.com.ar.old
-rw-r--r-- 1 named named 603 Nov 12 2003 ./a/a/aaqct.com.ar.old
legionx
6 REPLIES 6
Geoff Wild
Honored Contributor

Re: command find + sort

Not too sure if you are just providing info or you are having trouble...

Try this:

find ./ -name *.old | xargs ls -ltr {} \;|more

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Jairo Campana
Trusted Contributor

Re: command find + sort

Not too sure if you are just providing info or you are having trouble
********************************
yes, work with errors
find ./ -name *.old | xargs ls -ltr {} \;|more

-rw-r--r-- 1 named named 347 Aug 15 2001 ./a/r/aroxt.com.old
-rw-r--r-- 1 named named 361 Aug 15 2001 ./a/r/arihernandez.com.old
-rw-r--r-- 1 named named 353 Aug 21 2001 ./a/r/arqsovic.com.old
--More--{}: No such file or directory
;: No such file or directory
{}: No such file or directory
;: No such file or directory
legionx
Geoff Wild
Honored Contributor
Solution

Re: command find + sort

What about:

find ./ -name *.old | xargs ls -ltr |more


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Rodney Hills
Honored Contributor

Re: command find + sort

Unfortunatelly "ls" is not consistent with displaying dates.

Here is a one liner that should work-
find . -name "*.old" | perl -ne 'chomp; print STDOUT (-M $_),"\t",$_,"\n"' | sort -n | cut -f2 | xargs -n1 ll -d

This works by getting the age of the file, prepending to the filename, then calling sort, then calling cut (to remove the file age), then xargs to do "ll" command.

HTH

-- Rod Hills
There be dragons...
Rodney Hills
Honored Contributor

Re: command find + sort

Geoffs solution is the most sound, although it won't work if you have a lot of files.

xargs will process the filenames in chunks, so that each chunk will be sorted, but not sorted as a whole.

my 2 cents...

-- Rod Hills

PS- gnu find command, available on the software porting and archive centre, has extended capabilities that might be of use to solve your problem.
There be dragons...
Muthukumar_5
Honored Contributor

Re: command find + sort

we can also use,

ls -ltr `find . -name "*.old"` | more

HTH.
Easy to suggest when don't know about the problem!