The below bash script is written for finding the files which are modified with in the last T second where T is supplied from the command line.
if [ $# -ne 1 ]; then
echo "Wrong number of argument"
exit 1
fi
for f in *
do
if [ -x "$f" ]; then
currenttime=$(date | awk '{print $4}')
modify=$(date -r "$f" | awk '{print $4}')
d_c=${currenttime:0:2}
m_c=${currenttime:3:2}
s_c=${currenttime:6:2}
d_m=${modify:0:2}
m_m=${modify:3:2}
s_m=${modify:6:2}
let "1d_c *= 24"
let "m_c *= 60"
let "second_c = d_c+m_c+s_c"
let "d_m *= 24"
let "m_m *= 60"
let "second_m=d_m+m_m+s_m"
let "diff=second_c-second_m"
if [ $diff -lt $1 ]; then
echo $f
fi
fi
do
ne
But I am getting the below error in that.
./recent.sh: line 46: let: 09: value too great for base (error token is "09")
./recent.sh: line 47: let: 09: value too great for base (error token is "09")
./recent.sh: line 49: let: 09: value too great for base (error token is "09")
I know that this error is coming due to the large value in the variable and I have to make the variable decimal but I don't know how to do it in my case(inside the let command, how to make them decimal).
let "1d_c *= "24"andlet "m_c *= "60", which completely break your Bash syntax. Please confirm that the code you have posted here is correct, and produces the errors you claim. (Hint: it doesn't. Your error-messages refer to lines 46, 47, and 49, but you've only posted 28 lines of code. Please fix.) - ruakhlet "1d_c *= "24"? you're missing a"char, but I don't believe you need any"chars. Also read up about arithmetic processing available in bash, i.e.(( m_m *= 60 )); echo "$m_m. - shellter