How do I compare the timestamp of two files?
I tried this but it doesn't work:
file1time=`stat -c %Y fil1.txt`
file2time=`stat -c %Y file2.txt`
if[$file1time -gt $file2time];
then
doSomething
fi
I printed both the time stamps, in order and it gives me
1273143480
1254144394
./script.sh: line 13: [1273143480: command not found
So basically if comparision is not working, I guess. Or if there is any other nice way than what I am doing, please let me know.
Thanks
Edit: Solved. There was no space in between if, so changing it to this works:
if [ $file1time -gt $file2time ]