1

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?

Thanks.

polyglot
  • 191

1 Answers1

2

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
madneon
  • 1,434