Welcome to the Linux Foundation Forum!

Can anyone help with my script

My script won't run the menu part works but it wont back up to the sub directory when choice 1 or choice 2 is inputed anyone got any ideas where i'm going wrong?

!/bin/bash

pause(){
read -p "Press [Enter] key to continue..." fackEnterKey
}

one(){
echo "Backup all files"
pause
}

do something in two()

two(){
echo "Backup selected files"
pause
}

function to display menus

show_menus() {
clear
echo "~~~~~"
echo " M A I N - M E N U"
echo "~~~~~"
echo "1. Backup all files"
echo "2. Backup Selected files"
echo "3. Exit"
}

read input from the keyboard and take a action

invoke the one() when the user select 1 from the menu option.

invoke the two() when the user select 2 from the menu option.

Exit when user the user select 3 form the menu option.

read_options(){
local choice
read -p "Enter choice [ 1 - 3] " choice
case $choice in
1) one ;;
2) two ;;
3) exit 0;;
*) echo -e "${RED}Error...${STD}" && sleep 2
esac
}

----------------------------------------------

Step #3: Trap CTRL+C, CTRL+Z and quit singles

----------------------------------------------

trap '' SIGINT SIGQUIT SIGTSTP

-----------------------------------

Step #4: Main logic - infinite loop

------------------------------------

while true
do

show_menus
read_options

if == one ;;
cp -r ~/outcome3/. ~/Backup_allfile
else == two ;;
cp -r ~/file/. ~/test/. ~/Backup_Selected_Files
done

Categories

Upcoming Training