0

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.