Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!amdahl!krs From: krs@uts.amdahl.com (Kris Stephens [Hail Eris!]) Newsgroups: comp.unix.shell Subject: Re: Comparing modified times of files Message-ID: Date: 23 Mar 91 18:52:37 GMT References: <930001@mjm.mjm.com> <6350@amc-gw.amc.com> Reply-To: krs@amdahl.uts.amdahl.com (Kris Stephens [Hail Eris!]) Organization: Amdahl Corporation, Sunnyvale CA Lines: 31 In article <6350@amc-gw.amc.com> stuart@tfatf.amc.com (Stuart Poulin) writes: >In article <930001@mjm.mjm.com> mjf@mjm.mjm.com (Mark Fresolone) writes: >> ls -t file1 file2 | line # returns newest >> ls -rt file1 file2 | line # returns oldest > >Or if you don't have "line": > ls -t file1 file2 | (read XX; echo $XX) # returns newest > ls -rt file1 file2 | (read XX; echo $XX) # returns oldest Okay, so this is sort of fun. How 'bout: # sh or ksh fragment newest() { set -- ls -t $* 2>/dev/null echo $1 } oldest() { set -- ls -rt $* 2>/dev/null echo $1 } echo "The newest existing file in your list is `newest $*`" echo "The oldest existing file in your list is `oldest $*`" # end sh or ksh fragment ...Kris -- Kristopher Stephens, | (408-746-6047) | krs@uts.amdahl.com | KC6DFS Amdahl Corporation | | | [The opinions expressed above are mine, solely, and do not ] [necessarily reflect the opinions or policies of Amdahl Corp. ]