Find the answer to your Linux question:
Results 1 to 4 of 4
like I have var = hello world hello universe now I want to do search, how can I do that? ser = "hello"...
  1. #1
    Linux Newbie
    Join Date
    Jan 2008
    Posts
    114

    Can we do patter matching in a string in Shell

    like I have

    var = hello world hello universe

    now I want to do search, how can I do that?

    ser = "hello"
    Switched to Scripting

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    For simple search, use grep. For search and replace, use sed. Do this at the command line:
    Code:
    man grep
    man sed
    If man pages are not installed on your system, google this:
    Code:
    man grep solaris
    man sed solaris
    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    You can either pipe the text into grep, or use Bash's regex match operator:
    http://www.tldp.org/LDP/abs/html/bas...#REGEXMATCHREF
    DISTRO=Arch
    Registered Linux User #388732

  4. #4
    Linux Newbie
    Join Date
    Jan 2008
    Posts
    114
    I was expecting both of you

    Now again working shell after long time.

    Understood

    thanks
    Switched to Scripting

Posting Permissions

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