Here i m highlighting the best practice to delete a file when there is a variable involved as a file name.
#!/bin/bash
echo "Enter file or folder to delete from tmp"
read input
if [ ! -f "/tmp/$input" ]
then
echo "File Doesnt Exist"
else
rm -f "/tmp/$input"
fi
rm -f, --force
ignore nonexistent files, never prompt
No comments:
Post a Comment