I have a folder TEST with some files (with the occurence abc) I want to delete. I use :
for filename in TEST/*; do
if [ -f "$filename" ]; then
if [[ "$filename" == *abc* ]]; then
rm $filename && echo "The files $filename are well deleted" ;
else printf "The files were already deleted" ;
fi;
fi;
done
What I want, is to print the "The files were already deleted" only once . For example, after removing the files with the occurence abc , if it remains 4 files inside the folder TEST , that will print the sentence "The files were already deleted" 4 times, and not one like I would like to.
Any idea?