LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 09-27-2003, 11:53 AM   #1
stodge
Member
 
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:

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
 
  


Reply


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 10:22 PM
Help! Script or commanded needed to replace text in a file farmerjoe Programming 3 01-02-2005 06:59 PM
help! Script or command needed to replace text in a file. farmerjoe Linux - Newbie 2 01-02-2005 04:07 PM
Script to search and replace in text file - kinda... jeffreybluml Programming 45 11-07-2004 06:37 PM
Search and replace text in file using shell script? matthurne Linux - Software 2 11-02-2004 11:11 AM


All times are GMT -5. The time now is 01:50 AM.

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