[kwlug-disc] Block level search and replace
Insurance Squared Inc.
gcooke at insurancesquared.com
Wed Feb 23 17:28:49 EST 2011
In the loop below, what happens (if anything) if the information wraps
lines, i.e. instead of
for f in *.html ; do
sed 'above expr'< "$f"> "/something/newset/$f"
done
We have
for f in *.html ; do
sed 'above
expr'
< "$f"> "/something/newset/$f"
done
Does that change anything?
On 23/02/11 05:13 PM, Chris Frey wrote:
> On Wed, Feb 23, 2011 at 05:04:02PM -0500, Insurance Squared Inc. wrote:
>
>> I've got an old script I can't quite get working. What's the best way
>> to do a block search and replace across many files? i.e. the text I'm
>> searching and replacing might be a bit longer than a small line. like:
>> find:
>> <body><center>
>> Replace with:
>> <body><A href="http://www.example.com">Home</a> :<a
>> href="/link2">Link2</a> :<a href="/link3">Link 3</a>
>>
> If you can guarantee that<body><center> are on one line, you could try:
>
> sed 's,<body><center>,<body><A href="http://www.example.com">Home</a> :<a href="/link2">Link2</a> :<a href="/link3">Link 3</a>,'< filename1> filename2
>
> To do that for a bunch of files, wrap it in a for loop:
>
> mkdir /something/newset
> cd oldset
> for f in *.html ; do
> sed 'above expr'< "$f"> "/something/newset/$f"
> done
>
> - Chris
>
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>
>
More information about the kwlug-disc
mailing list