The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-05-2009
prismtx prismtx is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 24
Execute multiple commands in a find

I am checking that a file is older than a reference file that I build with a touch command before processing it. If it is not old enough, I want to sleep for an hour and check again.

My problem is if it is old enough to process, I want to exit when I am done, but I cannot find a way to exit after doing a successful find. It keeps looping and processing until the count is fulfilled. I have tried doing an exit as a -exec on the find as shown below and I have tried checking the status of the find with $?, but it is always "0" whether the file is old or new.

Any ideas?

Code:
typeset -i  count=1

while ((${count} <= 3))
do
 find  /export/home/MYACCT/ -type f -name \ar5.log ! -newer /WORKDIR/REF -exec /export/home/MYACCT/datetest.ksh \; -exec exit 0 \;
   count=${count}+1
   sleep 3600
done

echo "No file to process"
exit 5