Xref: utzoo comp.unix.questions:24386 alt.sources.d:726 Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!samsung!rex!ames!amdcad!pyramid!ctnews!risky!chrisb From: chrisb@risky.Convergent.COM (Chris Bertin) Newsgroups: comp.unix.questions,alt.sources.d Subject: Re: how to compare file modification time (whole dir tree?) Message-ID: <303@risky.Convergent.COM> Date: 6 Aug 90 16:54:44 GMT References: <1990Jul27.153223.12416@chinet.chi.il.us> <1446@chinacat.Unicom.COM> <1990Aug3.155651.12006@sq.sq.com> Organization: Convergent Technologies, San Jose, CA Lines: 49 In article <1990Aug3.155651.12006@sq.sq.com>, lee@sq.sq.com (Liam R. E. Quin) writes: > fritz@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@risky.Convergent.COM Unisys | or (408) 435-3762 | ...!uunet!pyramid!ctnews!risky!chrisb