using bold font the file I called choice.sh and put in /usr/local/bin folder (with Debian12)
============ start of choice.sh file ===================
title="Select example"
prompt="choice.sh ..... Pick an option by number or 6 to Quit, nothing to display option list:"
options=("1 = check memory usage" "2 = clear swap memory" "3 = release Memory" "4 = check for updates with list" "5 = update " )
echo "$title"
PS3="$prompt "
select opt in "${options[@]}" "Quit"; do
case "$REPLY" in
1) free; date "+%T" ;;
2) sudo dphys-swapfile swapoff ; sudo dphys-swapfile swapon ; free ;;
3) free ; echo 1 | sudo tee /proc/sys/vm/drop_caches; free ;;
4) sudo apt update && apt list --upgradable -a ;;
5) sudo apt dist-upgrade ;;
$((${#options[@]}+1))) echo "Goodbye! "; break;;
*) echo "Invalid option. Try another one.";continue;;
esac
done
============ end of choice.sh file ==============
It prints out on the screen.
Select example
1) 1 = check memory usage 3) 3 = release Memory 5) 5 = update
2) 2 = clear swap memory 4) 4 = check for updates with list 6) Quit
choice.sh ..... Pick an option by number or 6 to Quit, nothing to display option list:
This "hobby" of checking the swap memory started many months ago, when the whole system used to "lock up", the only thing I could do was to press the system reset button and reboot the system. Now by using the sudo dphys-swapfile swapoff ; sudo dphys-swapfile swapon I hardly get any system lock ups.
This choice.sh saves me using the "up arrow" on the keyboard looking for the most commonly commands I use, like if there is a system update. with "sudo apt update" in the 4) line then if there is a update it gives the list, before to use option 5) to update the system with apt list --upgradable -a
I make the changes using Mousepad text editor in a file called makesh.txt
then go to my command line terminal logged on as "root" user and do cp makesh.txt choice.sh to make the choice.sh file
and also do cp makesh.txt choice.txt to backup a copy of the last changes I made to choice.sh file
I hope you get something out of it, You could even change the 1) 2) 3) 4) 5) options even add on some more, I have not tried 10) yet as a option. My next move is to learn more about BASH files and hopefully might be able to add a bit of color to the menu (Option List)
============ start of choice.sh file ===================
title="Select example"
prompt="choice.sh ..... Pick an option by number or 6 to Quit, nothing to display option list:"
options=("1 = check memory usage" "2 = clear swap memory" "3 = release Memory" "4 = check for updates with list" "5 = update " )
echo "$title"
PS3="$prompt "
select opt in "${options[@]}" "Quit"; do
case "$REPLY" in
1) free; date "+%T" ;;
2) sudo dphys-swapfile swapoff ; sudo dphys-swapfile swapon ; free ;;
3) free ; echo 1 | sudo tee /proc/sys/vm/drop_caches; free ;;
4) sudo apt update && apt list --upgradable -a ;;
5) sudo apt dist-upgrade ;;
$((${#options[@]}+1))) echo "Goodbye! "; break;;
*) echo "Invalid option. Try another one.";continue;;
esac
done
============ end of choice.sh file ==============
It prints out on the screen.
Select example
1) 1 = check memory usage 3) 3 = release Memory 5) 5 = update
2) 2 = clear swap memory 4) 4 = check for updates with list 6) Quit
choice.sh ..... Pick an option by number or 6 to Quit, nothing to display option list:
This "hobby" of checking the swap memory started many months ago, when the whole system used to "lock up", the only thing I could do was to press the system reset button and reboot the system. Now by using the sudo dphys-swapfile swapoff ; sudo dphys-swapfile swapon I hardly get any system lock ups.
This choice.sh saves me using the "up arrow" on the keyboard looking for the most commonly commands I use, like if there is a system update. with "sudo apt update" in the 4) line then if there is a update it gives the list, before to use option 5) to update the system with apt list --upgradable -a
I make the changes using Mousepad text editor in a file called makesh.txt
then go to my command line terminal logged on as "root" user and do cp makesh.txt choice.sh to make the choice.sh file
and also do cp makesh.txt choice.txt to backup a copy of the last changes I made to choice.sh file
I hope you get something out of it, You could even change the 1) 2) 3) 4) 5) options even add on some more, I have not tried 10) yet as a option. My next move is to learn more about BASH files and hopefully might be able to add a bit of color to the menu (Option List)
Last edited:

