Shell search and replace

Discussion in 'Site & Server Administration' started by vinyl, Oct 2, 2005.

  1. #1
    Can anyone suggest me free shell script which can search (and replace) desired string in multiple files... for instance, Id like to replace any instance of string in all sites pages I host at certain server, so script should recursively go thru all folders & files under /home partition and replace all instances with something...
     
    vinyl, Oct 2, 2005 IP
  2. forkqueue

    forkqueue Guest

    Messages:
    401
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sounds like you just need

    perl -pi -e 's/foo/bar/' *

    To replace foo with bar in all files.
     
    forkqueue, Oct 2, 2005 IP
  3. vinyl

    vinyl Well-Known Member

    Messages:
    302
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    165
    #3
    The problem with that is that it wont do recursive thing, than search only for files in current folder... anyhow, I found solution in rpl, which has -R option -- somebody might find it usefull, so I decided to post it here.
     
    vinyl, Oct 4, 2005 IP