Find the answer to your Linux question:
Results 1 to 4 of 4
hi all, i am trying small shell script, i need to replace string "/usr/local" with "/root", this pattern may occurs more then one and i need to replace all, i ...
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    7

    string replacement,

    hi all,

    i am trying small shell script, i need to replace string "/usr/local" with "/root", this pattern may occurs more then one and i need to replace all,

    i am unable to do it using 'sed'

    please help me..

    thank u

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    Have you tried using perl ?

    Code:
    perl -pe "s/\/usr\/local/\/root/g" <file>
    Will dump <file> to stdout with any changes the regex makes

    Code:
    perl -i -pe "s/\/usr\/local/\/root/g" <file>
    Will make the changes directly in <file>
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    7
    matonb thank you, i tried second one that is working fine, thanks agian

  4. #4
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    No problem
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

Posting Permissions

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