Попробуйте обернуть ваш скрипт как функцию и вызвать его рекурсивно:
#/bin/bash
do_file_action(){
echo "Select an option from copy , remove , rename , linking"
#read in user input into the action variable
read action
...
echo "Do you want to perform another file operation (yes/no) ?"
read answer
if [ $answer = yes ]
then do_file_action
exit 0
elif [ $answer = no ]
then echo "Exiting Program"
exit 0
fi
fi
}
do_file_action
Попробуйте выполнить следующие действия в указанном порядке:
sudo rm /var/lib/dpkg/lock
sudo dpkg --configure -a
# only continue if the above results in zero packages left to configure.
sudo apt-get dist-upgrade