[Gllug] Most Recent File
Steve Nelson
sanelson at gmail.com
Wed Nov 23 13:31:58 UTC 2005
On 11/23/05, Peter Grandi <pg_gllug at gllug.to.sabi.co.uk> wrote:
> pg_gllug> Great are the powers of 'date'(1)! :-)
>
> pg_gllug> THEN="`date +'%s' -d 'last friday 17:37'`"; NOW="`date +'%s'`"
> pg_gllug> find "$DIR" -mmin "`expr '(' \"$NOW\" - \"$THEN\" ')' / 60`"
I like the -d, --date=STRING form of date very much - thanks for
reminding me of that!
> STAMP="`tempfile`"; trap "rm -f '$STAMP'" 0
> touch -d 'last friday 17:37' "$STAMP"
> find "$DIR" -newer "$STAMP"
> rm -f "$STAMP"; trap 0
Yes that's similar to what I originally posted - touch a file using -t
and do a find -newer. I like the way this is embeddable though.
Also because I spend lots of time in Solaris, I tend to forget the -d
options provided in GNU coreutils. Very nice indeed.
S.
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list