how do I create a simple Shell script that asks for a simple input from a user and then runs only the command associated with the predefined choice, for example
IF "ON"
Backup Server
ELSEIF "OFF"
Delete Backups
ELSEIF "GREY"
Send Backups
ENDIF
how do I create a simple Shell script that asks for a simple input from a user and then runs only the command associated with the predefined choice, for example
IF "ON"
Backup Server
ELSEIF "OFF"
Delete Backups
ELSEIF "GREY"
Send Backups
ENDIF
Hi there is simple example how to do it
for source click here source
You can take input from a user via
read
and you can use acase ... esac
block to do different things.Read takes as its argument, the name of the variable into which it will store it's value
Will take in a vaue from the user and store it in
$foo
.To prompt the user for input you will need to use echo.
Finally, most shell scripts support the case operator. Which take the form
Putting it all together: