LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Script file to replace large text blocks in files? (http://www.linuxquestions.org/questions/linux-software-2/script-file-to-replace-large-text-blocks-in-files-97499/)

stodge 09-27-2003 10:53 AM

Script file to replace large text blocks in files?
 
Does anyone have a Linux shell script to do the following:

Walk through all sub-directories below the current one and replace the text in files of a specified extension with the given text. The only kicker is, I want to replace a block of text from each file that is probably about 10 lines long, so I don't know if I can just use something like this:

Code:

#! /bin/sh
# filename: replaceall
find . -type f -name '*.txt' -print | while read i
    do
        sed 's|foo|bar|g' $i > $i.tmp && mv $i.tmp $i
    done


Thanks


All times are GMT -5. The time now is 02:34 AM.