in reply to Re: Finding Oldest File in a Directory
in thread Finding Oldest File in a Directory

almost...
ls -t *BOT* | head -1
or converted to a one liner in perl...
perl -e 'my %bot; for ( sort { ( $bot{ $a } ||= ( -M $a ) ) <=> ( $bot +{ $b } ||= ( -M $b ) ) } glob "\*BOT\*" ) { print "$_\n"; last; }'

-M

Free your mind

Replies are listed 'Best First'.
Re^3: Finding Oldest File in a Directory
by Perl Mouse (Chaplain) on Oct 06, 2005 at 09:30 UTC
    almost...
    ls -td *BOT* | head -1
    Or you'll get the first file in the oldest directory containing BOT in its name (assuming no file whose name contains BOT is older)

    This still has the possibility of returning a directory name though. Under Unix, this still is a file, although when people say "file", they usually want to exclude directories.

    Perl --((8:>*
      No, the -d option specifically limits the output to directories only, not its absence as you imply.

      -M

      Free your mind

        No, the -d option specifically limits the output to directories only, not its absence as you imply.
        I know. That's why I wrote: This still has the possibility of returning a directory name though. -d implies that ls won't show the content of the directories, just the name. Which is exactly what I intended.
        Perl --((8:>*