1
#!/bin/bash
echo "Are you sure you want to move this file to the Recycle Bin?" "(Yes/No)"
read ans
case "$ans" in
        Yes) echo "$(readlink -f $1)" >> "$HOME/TrashLog" && mv "$1" "$HOME/my-documents/mydir01/Trash" ;;
        No) echo "File was NOT deleted and remains. ";;
esac

This script moves a file to a trash folder in which acts as a recycling bin. The 2nd script I'm trying to make should take the location of the original file (stored in TrashLog as a file path) and restore the file to its original location. Here's what I had so far (which isn't working).

#!/bin/bash
restore=$(find my-documents/* | grep $1)
filename=$(readlink -f $restore)
mv -i "$filename" "$(grep $1 $HOME/TrashLog)"
Craig
  • 31

0 Answers0