I'm new to Linux and I've written a script to move files to a specified folder (fake delete).
However it will only mv
the file in the same folder as my script. Is there a way I can make this executable to delete any file no matter the location?
I.e.:
DELETE test ..(test is in ~/my-documents folder) (delete script in ~/my-applications/bin folder)
The script is below.
echo do you want to delete this? (yes/no) \n
read ans \n
case "$ans" in
Y¦y¦yes ) echo "$readlink -f "$1")" >>"$HOME/DustbinLog" && mv "$1" "$HOME/my-applications/bin/dustbin";;
N¦n¦no echo "File not moved!";;
esac
DELETE ~/my-documents/test
. – IanC Nov 27 '16 at 00:47or
operator (should be|
, not¦
), the second option from thecase
is missing a)
. I also would use a default case in the "no" answer (*)
). That way, if the user types anything but Y/y/yes the file won't be moved and the message will be prompted. – IanC Nov 27 '16 at 00:54