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


Groups > comp.unix.shell > #4450

Re: Find the oldest files without using ls -tr

From Ivan Shmakov <oneingray@gmail.com>
Newsgroups comp.unix.shell
Subject Re: Find the oldest files without using ls -tr
Date 2012-03-14 12:31 +0700
Organization Aioe.org NNTP Server
Message-ID <86lin3bvf9.fsf@gray.siamics.net> (permalink)
References <29316929-0f1b-466e-9041-3113bf4fe6c5@i5g2000yqo.googlegroups.com> <jjnvr7$et9$1@speranza.aioe.org>

Show all headers | View raw


>>>>> Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

[...]

 > Well, you need some tool to inspect the date information of the file,
 > and if you want the oldest file you'd have to inspect the dates of
 > all your files to find the oldest.  So the simplest is indeed ls -tr
 > or use stat(1) to determine (and then compare) the dates yourself.

	I'd note that find(1)'s -printf option is indeed such a tool,
	and a trivial awk(1) script could be used to determine the
	oldest file or files.  Consider, e. g.:

$ find -printf %T@\\t%p\\n \
      | LC_ALL=C awk 'min == "" || $1 < min {
                          min = $1; f = $2;
                          next;
                      }
                      END { print f; }' 

	And it's not that hard to extend the above to print the N oldest
	files instead.

[...]

-- 
FSF associate member #7257

Back to comp.unix.shell | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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