so when i use rm file -i vv bb i can delete the first file vv but i cant seem to delete the second file bb as i tried to use shift on it, but it seems that it delete the first one and stops it without looping it to the next file. what is wrong with my coding ?
#!/bin/bash
function removei () {
clear
if [[ -d $file ]]; # -d allows to check if the value is a directory
then
echo -e "are you sure you want to remove this directory (y/n)"
read ANSWER
case "$ANSWER" in
[Yy]) echo "the directory $file has been deleted"
mv $file $HOME/deleted
shift
;;
[Nn]) echo -e "exiting"
exit
;;
*) echo "Answer y or n"
;;
esac
elif [[ -f $file ]]; # -f allows to check if the value is a file
then
echo "are you sure you want to remove the file (y/n)"
read ANSWER1
case "$ANSWER1" in
[Yy]) echo "the file $file has been deleted"
mv $file $HOME/deleted
shift
echo "the file $file has been deleted"
mv $file $HOME/deleted
shift
;;
[Nn]) echo "exiting"
exit;;
*) echo "Answer y or n";;
esac
else
echo "$file does not exist"
fi
}
file=$2
while getopts "ivfrR:" option
do
case $option in
i) removei;;
v) removev;;
f) removef;;
esac
shift 1
done