Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-27-2003, 10:53 AM   #1
Registered: Jan 2002
Posts: 52

Rep: Reputation: 15
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:

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



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace text of unknown content with other text in file brian0918 Programming 15 07-14-2005 09:22 PM
Help! Script or commanded needed to replace text in a file farmerjoe Programming 3 01-02-2005 05:59 PM
help! Script or command needed to replace text in a file. farmerjoe Linux - Newbie 2 01-02-2005 03:07 PM
Script to search and replace in text file - kinda... jeffreybluml Programming 45 11-07-2004 05:37 PM
Search and replace text in file using shell script? matthurne Linux - Software 2 11-02-2004 10:11 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:44 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration