I'm trying to create a script that would allow me to identify the sucessful removal of a file. Here's what i put together so far, let me know if it's correct or not.
The -z test will not work in Bourne shell. It will in Korn - not sure about Bash.
The FILE_FIND command needs backticks - not quotes.
Also, in some forms of 'find' you need a -print command.
So...
FILE_NAME="cactus.dat"
FILE_FIND=`find / -name $FILE_NAME -print`
if [ -z $FILE_FIND ] ;then
# Zero string length - file not found
echo "cactus.dat was removed successfully"
else
echo "cactus.dat was not removed successfully"
fi
The -z test will not work in Bourne shell. It will in Korn - not sure about Bash. Also, in some forms of 'find' you need a -print command.