I'm working on automated scripts running on a Linux box (Debian). Those scripts are started from a scheduler and are manipulating files within their own directories.
At the end of the scripts, I need to delete temporary files.
Currently, I've something like this :
#check that some variables are not empty if [[ -z $var1 || -z $var2 || -z $var3 ]]; then echo "Some var is empty" exit 1 fi workingdir=$var1/$var2 #some checks on working directory if [[ ! -d $workingdir ]]; then echo "Directory error" exit 1 fi cd $workingdir if [[ $(pwd) != $workingdir ]]; then echo "Change directory error" exit 1 fi #...here goes the main part of the script #and at the end, the "cleaning" if [[ -d $workingdir/temp/$var3 ]]; then find $workingdir/temp/$var3 -delete; fi
Do you have any idea I could use to reduce the risk of removing anything wrong?