how to compare file modification time (whole dir tree?)
Chris Bertin
chrisb at risky.Convergent.COM
Tue Aug 7 02:54:44 AEST 1990
In article <1990Aug3.155651.12006 at sq.sq.com>, lee at sq.sq.com (Liam R. E. Quin) writes:
> fritz at mercury.caltech.edu (Fritz Nordby) writes:
> > Am I missing something here, or will the following [work]?
> >
> >#!/bin/sh
> >case $# in 2);;*)echo "usage: ${0:-newer} file1 file2" >&2;exit 2;;esac
> >[ ! -f "$2" -o -f "$1" -a "X`/bin/ls -t \"\$1\" \"\$2\"`" = "X$1
> >$2"] >/dev/null 2>&1
>
> I have no idea. It *might* have won the Obfuscated Shell Contest, except
> that there isn't one. At first I thought it was a perl script.
> I have had a go at expanding this a little below...
....
> Lee
Expanded doesn't mean better.
>
> # valilidate arguments:
> case $# in
> 2) ;;
> *) echo "usage: ${0:-newer} file1 file2" >&2
> exit 2
> ;;
> esac
The comment is useless and 'valilidate' is a new word to me. It is obviously
an argument validation check, since it is checking $# and echo-ing a usage
statement.
>
> test x"${LsOutput}" = x"${FirstNewer}
> exit $?
>
The 'exit' statement is useless. 'test' will return the right exit code.
To go back to the original script, it really doesn't need to open /dev/null.
Most people do that when they want to discard output, but why not close
the apropriate file descriptor?
> >[ ! -f "$2" -o -f "$1" -a "X`/bin/ls -t \"\$1\" \"\$2\"`" = "X$1
> >$2"] >/dev/null 2>&1
[ ! -f "$2" -o -f "$1" -a "X`/bin/ls -t \"\$1\" \"\$2\"`" = "X$1 $2"] >&- 2>&-
Chris
--
Chris Bertin | chrisb at risky.Convergent.COM
Unisys | or
(408) 435-3762 | ...!uunet!pyramid!ctnews!risky!chrisb
More information about the Comp.unix.questions
mailing list