1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

bulk search and replace for multiple lines?

Discussion in 'General Programming Chat' started by Viltedali, Dec 5, 2008.

  1. Viltedali

    Viltedali Regular Member

    Joined:
    Feb 10, 2008
    Messages:
    305
    Likes Received:
    32
    Location:
    Midwest-US
    Is anyone aware of a free, preferably lightweight application that can do a search and replace for multiple lines for multiple files?

    For example, I have a PHP script that has maybe 20 lines of code that I want to replace with just one line of code - "<?php include("footer.php"); ?>", and I have about 100 files that need this change.

    I have the program "Programmers Notepad 2" that has a bulk search and replace feature, but it seems to me that you cannot replace more than one line. It gives you the option of using regular expressions, but I know nothing about them and if they would be the solution or not.
     
  2. bpaw

    bpaw Junior Member

    Joined:
    Aug 9, 2008
    Messages:
    175
    Likes Received:
    48
    Home Page:
    If you are comfortable with *nix, look into the program "sed"

    You just run that through a for loop for all the files should be replaced.
     
  3. 195471

    195471 Regular Member

    Joined:
    Oct 11, 2008
    Messages:
    417
    Likes Received:
    260
    Dreamweaver's built-in find-and-replace tool is the best solution that I know of. You can make global changes to hundreds or thousands of files in one shot. DW isn't free of course, but there's a free trial.

    There's also this tool, which I haven't used, but it looks like it would get the job done:

    Code:
    http://www.bestcode.com/html/findreplace.html