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.
1 Color: Green Code: 1
2 Color: Yellow Code: 2
3 Color: red Code: 3
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 :
/bin/sh a=null while [ "$a" ] || [ ! "$ choices"]; do echo "choice:" read "choice" a = $ ($ echo choice | sed 's / [1-3] [1-3 ]//') done echo "bravo"
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.
|Tags: shell script, unix|
|Thread Tools||Search this Thread|
|Similar Threads for: "Unix Shell Script"|
|Thread||Thread Starter||Forum||Replies||Last Post|
|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|
|Shell Script Formatting||abhi701||Software Development||1||04-07-2009 04:30 PM|
|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 04:29 PM|