I am trying to make a Bash Script that has 4 choices and prompts the user to select an option. Each option corresponds to a Linux Command operation. Can someone give me a bash example on how could this be implemented?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Simple user selection example:
#!/bin/bash do_exit=0 while [[ $do_exit == 0 ]]; do echo read -s -n1 answer case $answer in 'l' ) ls -l ;; 'm' ) free ;; 'd' ) df ;; 'q' ) do_exit=1 ;; *) echo 'Invalid selection' ;; esac done