Re: [SLUG] timpestamps in bash

From: Eric Jahn (eric@ejahn.net)
Date: Fri Jul 25 2003 - 00:38:54 EDT


thanks, everyone! find -newer should do the trick! :)

On Thu, 2003-07-24 at 23:39, Eben King wrote:
> On Thu, 24 Jul 2003, Eric Jahn wrote:
>
> > Is there a way to get timestamp info on a single directory or file
> > without parsing ls -l output? I'm trying to dynamically choose the
> > backup folder depending on which is older... What would be really cool
> > is an "is older than" comparison. I couldn't find anything in the bash
> > literature except ls -l stuff. Thank you!
>
> Well, there's the '-newer' flag to 'find'; so I guess you could do
> something like:
>
> . /usr/local/lib/untested-code
>
> if [[ -n `find dir1 dir2 -maxdepth 0 -newer dir1` ]] then
> # dir1 is older
> else if [[ -n `find dir1 dir2 -maxdepth 0 -newer dir2` ]] then
> # dir2 is older
> else
> # same age
> fi
>
> ... BICBW. Try on comp.unix.shell .



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:55:58 EDT