I am try to compare the two time file based on their modify/lastchange time stamp & then copy the file to some folder code below
#!/bin/sh
cd /sapmnt/audit/
echo $PWD
t1= stat -c %z audit.log20151019115132
cd /var/log/audit/
echo $PWD
t2= stat -c %z audit.log.3
echo $t1
echo $t2
if [ $t2 -nt $t1 ];
then
echo "PASS"
else
echo "Fail"
fi
output:
/sapmnt/audit
2015-10-19 11:51:32.189657200 +0000
/var/log/audit
2015-10-20 17:25:01.000000000 +0000
PASS
The problem is that it always output Pass either if i exchange the condition to the [ $t1 -nt $t2 ]
.