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.

4

1 Answer 1

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.