Hi there, i currently dont have access to my linux machine and need to get these script files sent to someone. Can someone please create .sh files for me with the code that i have displayed below. It would be very very helpfull.
There are 3 different scripts and it would be great if someone could put them in .sh files and send them to me. Thanks in advance! xx
#Delete script
#
dustbin=/home/08012109/unix/dustbin
# making a varible for the dustbin so I don't repeatedly have to type out the full path
if [ -d $dustbin ]; then
echo "Dustbin found"
else
echo "Creating Dustbin"
mkdir $dustbin
fi
#
# if dustbin doesn't exist mkdir dustbin.
if [ -f $1 ]; then
echo "file found"
echo "$1 moved to dustbin"
else
echo "file not found"
echo "can't move $1 to dustbin"
fi
#
# Validating file exists
mv $1 $dustbin
#
# 'deleting' file by simply moving it to dustbin.
exit 0
# end of script
# restore script
#
case "$1" in
-n)
echo where do want the file to be moved to?
read loc
echo moving file $2 to $loc....
mv dustbin/$2 $loc
;;
*)
echo moving file $1 to 08012109/linux...
mv dustbin/$1 /home/08012109/linux
;;
esac
# Trash script
#
#
if [ -d dustbin ]; then
echo "dustbin found"
else
echo "there's no dustbin to empty"
exit 0
fi
#
#if dustbin doesn't exist throw error 'there's no dustbin to empty'
case "$1" in
-a)
if (test -z "$(ls dustbin)" );
then
echo "bin already empty"
else
rm dustbin/*
echo dustbin emptied
fi
#
#bin emptied
;;
-i)
echo "-i chosen"
;;
-ai)
if (test -z "$(ls dustbin)" );
then
echo "bin already empty"
else
rm -irv dustbin/*
fi
;;
*)
echo "chosen nothing"
;;
esac
#
# use a case statement for each of the options and also one for the combination of options. -i and regular versions not working correctly