-
Unix Shell Script
My problem is as follows: I have a prompt asking the user to choose among several choices to read from a file, I would like to limit the choice of the user only, and with only two choices and recover the parameters choice selected.
Example:
1 Color: Green Code: 1
2 Color: Yellow Code: 2
3 Color: red Code: 3
Choice:
The parameters (Green 1) and (yellow, 2) and (red, 3) represents when viewing parameters $ 2 and $ 4.
If the user chooses options 1 and 3 on a table tab [i] should be filled with the parameters (green, 1 red, 3)
Thank you in advance for your help.
-
Try this :
Code:
/bin/sh a=null while [ "$a" ] || [ ! "$ choices"]; do echo "choice:" read "choice" a = $ ($ echo choice | sed 's / [1-3] [1-3 ]//') done echo "bravo"
-
It is not very clear, I have not grasped the purpose of your script from the fact (1.2) or otherwise: (
-
My script meets your needs ^ ^. It asks the user a choice. Then, the response of the user will move in sed, and erase all the answers like "[1-3] [1-3]" ([1-3] = any number between 1 and 3 included). And the results are stored in the variable $ a. At this stage, if a $ applies "is that the answer in the form that you wanted.
Page generated in 1,714,158,714.43969 seconds with 10 queries