Re: How to sort the output from find
From: Chris F.A. Johnson (c.f.a.johnson_at_rogers.com)
Date: 09/22/03
- Previous message: Steven Feil: "Enscript custom fancy headers"
- In reply to: Andreas Kahari: "Re: How to sort the output from find"
- Next in thread: Bryan Dongray: "Re: How to sort the output from find"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 21 Sep 2003 22:35:38 GMT
On Sun, 21 Sep 2003 at 11:16 GMT, Andreas Kahari wrote:
> In article <3F6D79BE.7000303@jpl.nasa.gov>, Julia Bell wrote:
>> I'm using "find" to find a set of filenames that include a particular
>> string. But, then I need a way to sort that list by date (ls -lrt of
>> all the files that would found).
>>
>> Is there a straightforward way to do that?
>
> For a moderate number of files, this wil probably do it:
>
> find /some/path -type f -name "pattern" -print | xargs ls -lrt
>
> I say "moderate" since if 'find' finds too many files for one
> single invocation of 'ls', it will invoke it twice or more
> times. The files listed by 'ls' in one invocation will be
> sorted the way you want.
Then why use xargs? If the number is small enough for a single
invocation of ls by xargs, it should be small enough to work as
args to ls.
ls -lrt `find /some/path -type f -name "pattern" -print`
If you are using GNU find, you can format the output to your
liking and just pipe it to sort. "man find /printf" for more
details.
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Previous message: Steven Feil: "Enscript custom fancy headers"
- In reply to: Andreas Kahari: "Re: How to sort the output from find"
- Next in thread: Bryan Dongray: "Re: How to sort the output from find"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|