Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.perl.misc > #4731

Re: Find the oldest files without using ls -tr

From Ivan Shmakov <oneingray@gmail.com>
Newsgroups comp.unix.shell, comp.lang.perl.misc
Subject Re: Find the oldest files without using ls -tr
Date 2012-03-14 22:43 +0700
Organization Aioe.org NNTP Server
Message-ID <86ty1r89yi.fsf@gray.siamics.net> (permalink)
References <29316929-0f1b-466e-9041-3113bf4fe6c5@i5g2000yqo.googlegroups.com> <jjnvr7$et9$1@speranza.aioe.org> <86lin3bvf9.fsf@gray.siamics.net> <37ac79f8-664f-48cd-9107-029a99217e45@m13g2000yqi.googlegroups.com>

Cross-posted to 2 groups.

Show all headers | View raw


>>>>> Paul Branon <paulbranon@googlemail.com> writes:

	[Cross-posting to news:comp.lang.perl.misc, for obvious
	reasons.]

 >> $ find -printf %T@\\t%p\\n \

 > Ivan, what version of find are you using?

	As usual, GNU's.  (Unfortunately, GNU Findutils' documentation
	makes no mention that -printf is non-portable.)

	For a portable solution, a Perl-based one may fit, like:

$ find -exec perl -we 'foreach my $f (@ARGV) {
                           my @s = stat ($f)
			       or next;
                           printf("%d\t%s\n", $s[9], $f);
                       }' -- {} + \

	But note that one should post-process the output of the above
	Perl script even if the "oldest timestamp" logic is built into
	it, as there may be more filenames that could be safely passed
	to Perl by find(1) at one time.

-- 
FSF associate member #7257

Back to comp.lang.perl.misc | Previous | NextNext in thread | Find similar


Thread

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 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

csiph-web