Re: comparing two files last modification date
- From: Stephane CHAZELAS <stephane_chazelas@xxxxxxxx>
- Date: Thu, 13 Nov 2008 15:28:24 +0000 (UTC)
2008-11-13, 06:35(-08), puzzlecracker:
I have two files, say file1 and file2, I would like to find out which[...]
of these two files was modified last.
Some shells (ksh, zsh, bash) have [[ file1 -nt file2 ]].
In the standard toolchest, you've got "find -newer" and "ls -t"
if find file1 -prune -newer file2 -print | grep -q .; then
echo "file1 is newer than file2"
fi
Or:
NL='
'
case $(ls -td file1 file2) in
("file1${NL}file2") echo "file1 is not older than file2";;
("file2${NL}file1") echo "file2 is not older than file1";;
(*) echo >&2 error;;
esac
--
Stéphane
.
- Follow-Ups:
- Re: comparing two files last modification date
- From: puzzlecracker
- Re: comparing two files last modification date
- References:
- comparing two files last modification date
- From: puzzlecracker
- comparing two files last modification date
- Prev by Date: Re: comparing two files last modification date
- Next by Date: Re: comparing two files last modification date
- Previous by thread: Re: comparing two files last modification date
- Next by thread: Re: comparing two files last modification date
- Index(es):
Relevant Pages
|