dimanche 11 février 2018

How to find all files with the same basename within an IF statement using Unix

In the code below, I have an if statement attempting to exit the program if the user inputs 'safe_rm' as an argument. However it does not account for files with the same name in other directories. How can I improve the code so it does?

for i in $*
 do
  if [[  'safe_rm' = $i ]]
  then
   echo "Attempting to delete safe_rm - operation aborted"
  exit
 fi
done

Aucun commentaire:

Enregistrer un commentaire