Find the answer to your Linux question:
Results 1 to 6 of 6

Thread: Grep command

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Grep command


    suppost i have a file called NAMES
    and inside i have
    Code:
    Jason 78
    Peter 88
    David 99
    Anne 76
    how do i create a interactive menu for the user to type in all the names in one line as a sentence, and the result comes out in a sentence with the numebrs only?

    Type in names:
    Jason Anne David Peter
    result:
    78 76 99 88
    many thanks
    :P

  2. #2
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    What language are you trying to write this in? It always helps to know that first.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  3. #3
    Just normal shell command

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer
    Join Date
    Mar 2003
    Location
    U.S.A.
    Posts
    1,025
    Not trying to butt in but...... perl, c, java, php or something else is what he means, I think.
    Dan

    \"Keep your friends close and your enemies even closer\" from The Art of War by Sun Tzu\"

  6. #5
    oh sorry mate, my mistake
    yeah i'm trying to think of way of doing it in C

  7. #6
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    OK...i don't know C, but see if this helps: Try to read the lines of the file and compare them against each of the names (in an array would be EZiest). When you find a match, split the line at the space to get the number and put the numbers in an ordered array to print.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •