|
| |||||||||
| Tags: shell script, unix |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| 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. |
|
#2
| ||||
| ||||
|
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" |
|
#3
| ||||
| ||||
|
It is not very clear, I have not grasped the purpose of your script from the fact (1.2) or otherwise: ( |
|
#4
| ||||
| ||||
|
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. |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Unix Shell Script" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| shell script SSH not working | Lilya | Software Development | 9 | 16-10-2010 02:53 AM |
| Shell script with sed | Ameeryan | Software Development | 5 | 23-12-2009 02:29 PM |
| Parsing the file in Unix shell script | Macarenas | Software Development | 3 | 23-11-2009 11:32 AM |
| Need suggestion on book for Unix & shell scripting! | SamsherR | Software Development | 2 | 11-02-2009 05:22 PM |
| How to develop an interactive script in Unix systems | Allanoo | Software Development | 4 | 16-10-2008 05:29 PM |