-1

could somebody please help me find the problem with this code? getting this error "mv: cannot stat '~Desktop/RecyclingBin/testtest' : No such file or directory. It does exist and it is in the location ~Desktop/RecyclingBin/testtest

fileName=$1
fileLocation='cat ~/Desktop/RecyclingBin/logs/$fileName
if [ -z "$1" ]
   then
       echo "please enter a valid filename"
   else
       echo "do you want to restore?"
   read ans

   if [ "$ans" =="y" ]
   then 
       mv "~/Desktop/RecyclingBin/$fileName" "$fileLocation"
   fi
fi 
user3437235
  • 92
  • 3
  • 9

1 Answers1

0

The quotes prevent expansion of ~. Put it outside the quotes:

mv ~/Desktop/RecyclingBin/"$fileName" "$fileLocation"
Barmar
  • 596,455
  • 48
  • 393
  • 495