Comparing modified times of files
Kris Stephens [Hail Eris!]
krs at uts.amdahl.com
Sun Mar 24 04:52:37 AEST 1991
In article <6350 at amc-gw.amc.com> stuart at tfatf.amc.com (Stuart Poulin) writes:
>In article <930001 at mjm.mjm.com> mjf at 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 at 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. ]
More information about the Comp.unix.shell
mailing list