Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.unix.shell > #4484
| From | Ivan Shmakov <oneingray@gmail.com> |
|---|---|
| Newsgroups | comp.unix.shell |
| Subject | Re: Find the oldest files without using ls -tr |
| Date | 2012-03-15 10:41 +0700 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <86bony8r9a.fsf@gray.siamics.net> (permalink) |
| References | (2 earlier) <37ac79f8-664f-48cd-9107-029a99217e45@m13g2000yqi.googlegroups.com> <86ty1r89yi.fsf@gray.siamics.net> <u73739-sk21.ln1@anubis.morrow.me.uk> <jjqo6sUn64L1@news.in-ulm.de> <20120314190115.GB6799@yahoo.fr> |
>>>>> Stephane Chazelas <stephane_chazelas@yahoo.fr> writes:
>>>>> 2012-03-14 18:31:56 +0000, Sven Mascheck:
[...]
>> or just "find ... -exec {} +" which is posix and obsoletes xargs
> ... obsoletes xargs in direct combination with find, not in
> combination with other commands or with other usage patterns or with
> things like find ... | grep ... | xargs ...
Why one may want grep(1) instead of (GNU) find's own -name,
-regex, etc.?
> and as far as this thread is concerned:
> find . -printf '%T+\t%p\0' |
> tr '\n\0' '\0\n' |
> sort |
> head -n 3 |
> cut -f2- |
> tr '\n\0' '\0\n' |
> xargs -r0 ls -ldrt
> (GNU syntax)
Please note that both GNU sort and GNU Awk support NUL's as
record separators. So, it could be shortened (fork-wise) to:
$ find . -printf '%T+\t%p\0' \
| sort -z \
| gawk -vRS=\\0 -vORS=\\0 \
'NR > 3 { exit; }
1 { sub(/^[^[:blank:]]*\t/, ""); print $0; }' \
| xargs -r0 -- ...
Also, %T@ could provide a shorter key for sort(1) (with -n) to
use.
But still, there's no need to sort the stream as a whole just to
find the N lowest elements.
--
FSF associate member #7257
Back to comp.unix.shell | Previous | Next — Previous in thread | Next in thread | Find similar
Find the oldest files without using ls -tr Paul Branon <paulbranon@googlemail.com> - 2012-03-13 08:22 -0700
Re: Find the oldest files without using ls -tr Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-03-13 18:23 +0100
Re: Find the oldest files without using ls -tr Ivan Shmakov <oneingray@gmail.com> - 2012-03-14 12:31 +0700
Re: Find the oldest files without using ls -tr Paul Branon <paulbranon@googlemail.com> - 2012-03-14 08:28 -0700
Re: Find the oldest files without using ls -tr Ivan Shmakov <oneingray@gmail.com> - 2012-03-14 22:43 +0700
Re: Find the oldest files without using ls -tr Ben Morrow <ben@morrow.me.uk> - 2012-03-14 18:05 +0000
Re: Find the oldest files without using ls -tr Sven Mascheck <mascheck@email.invalid> - 2012-03-14 18:31 +0000
Re: Find the oldest files without using ls -tr Stephane Chazelas <stephane_chazelas@yahoo.fr> - 2012-03-14 19:01 +0000
Re: Find the oldest files without using ls -tr Ivan Shmakov <oneingray@gmail.com> - 2012-03-15 10:41 +0700
Re: Find the oldest files without using ls -tr Stephane Chazelas <stephane_chazelas@yahoo.fr> - 2012-03-15 08:13 +0000
Re: Find the oldest files without using ls -tr Ivan Shmakov <oneingray@gmail.com> - 2012-03-16 10:24 +0700
Re: Find the oldest files without using ls -tr Sven Mascheck <mascheck@email.invalid> - 2012-03-15 19:54 +0000
Re: Find the oldest files without using ls -tr Ben Morrow <ben@morrow.me.uk> - 2012-03-14 19:59 +0000
Re: Find the oldest files without using ls -tr Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-03-15 00:16 +0100
Re: Find the oldest files without using ls -tr Ben Morrow <ben@morrow.me.uk> - 2012-03-15 02:12 +0000
Re: Find the oldest files without using ls -tr Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-03-15 09:42 +0100
Re: Find the oldest files without using ls -tr Ben Morrow <ben@morrow.me.uk> - 2012-03-15 10:56 +0000
Re: Find the oldest files without using ls -tr tmcd@panix.com (Tim McDaniel) - 2012-03-15 15:46 +0000
Re: Find the oldest files without using ls -tr Ben Morrow <ben@morrow.me.uk> - 2012-03-15 16:49 +0000
Re: Find the oldest files without using ls -tr tmcd@panix.com (Tim McDaniel) - 2012-03-15 19:06 +0000
Re: Find the oldest files without using ls -tr Casper H.S. Dik <Casper.Dik@OrSPaMcle.COM> - 2012-03-15 17:13 +0000
Re: Find the oldest files without using ls -tr Stephane Chazelas <stephane_chazelas@yahoo.fr> - 2012-03-13 17:40 +0000
csiph-web