Results 1 to 4 of 4

Thread: Unix Shell Script

  1. #1
    Join Date
    Feb 2006
    Posts
    167

    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. #2
    Join Date
    Dec 2007
    Posts
    1,599
    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. #3
    Join Date
    Feb 2006
    Posts
    167
    It is not very clear, I have not grasped the purpose of your script from the fact (1.2) or otherwise: (

  4. #4
    Join Date
    Dec 2007
    Posts
    1,599
    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.

Similar Threads

  1. Shell script with sed
    By Ameeryan in forum Software Development
    Replies: 5
    Last Post: 23-12-2009, 02:29 PM
  2. Parsing the file in Unix shell script
    By Macarenas in forum Software Development
    Replies: 3
    Last Post: 23-11-2009, 11:32 AM
  3. Shell Script Formatting
    By abhi701 in forum Software Development
    Replies: 1
    Last Post: 04-07-2009, 04:30 PM
  4. Need suggestion on book for Unix & shell scripting!
    By SamsherR in forum Software Development
    Replies: 2
    Last Post: 11-02-2009, 05:22 PM
  5. How to develop an interactive script in Unix systems
    By Allanoo in forum Software Development
    Replies: 4
    Last Post: 16-10-2008, 04:29 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,577,024.53404 seconds with 16 queries