Operating System - HP-UX
1832880 Members
2438 Online
110048 Solutions
New Discussion

Re: Find related question

 
SOLVED
Go to solution
Sachin_29
Advisor

Find related question

I am trying to check whether a file is accessed in the last 24 hrs and if not then send an email .In ksh I am doing the following
test="`find . -name filename -atime +1 -print`"

if [ ${test} != "" ] ; then
Mail Me
fi

if the file is not accessed in 24 hours i get an error
test=
+ [ != ]
test: 0403-004 Specify a parameter with this command.
I guess somehow its not $test has no value?
not so sure why ? any suggestions
3 REPLIES 3
Sridhar Bhaskarla
Honored Contributor
Solution

Re: Find related question

Hi,

Put ${test} in quotes to bypass this error.

if [ "${test} != "" ]; then

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Sundar_7
Honored Contributor

Re: Find related question

better would be to use the -z option with if

if [[ -z "${test}" ]]
then
echo "File is not access in the last 24 hours"
else
echo "File has been accessed in the last 24 hours"
fi
Learn What to do ,How to do and more importantly When to do ?
Sachin_29
Advisor

Re: Find related question

thanks guys it works!!!