Every time I run this code I get the error File or directory doesn’t exist. Why?
read -p "Enter the filename/path of the file you wish to delete : " filename
echo "Do you want to delete this file"
echo "Y/N"
read ans
case "$ans" in
Y) "`readlink -f $filename`" >>~/TAM/store & mv $filename ~/TAM/dustbin
echo "File moved" ;;
N) "File Not deleted" ;;
esac
When I enter the file name/directory exactly and triple check its right I still get this error, but the readlink part works.
Paraphrasing/summarizing/extending my answer for a similar question:
I doubt you really meant to use
&instead of&&in your script."File Not deleted"is not a valid command on any Linux system that I have used. Perhaps you are missing anechothere?You have to fix your variable quotation. If the
filenamevariable contains whitespace, then$filenameis expanded by the shell into more than one arguments. You need to enclose it into double quotes:I do not see your script creating the
~/TAM/directory anywhere…