The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-25-2008
DocBrewer DocBrewer is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 6
How to supplement HTML tags with SED

I am cleaning up HTML with sed. With the regexp

<a name="[A-Za-z0-9 ?_.]+"></a><h[123]>[ ]*<span class="mw-headline" >[A-Za-z0-9 ?_.]+</span></h[123]>

I can find the tags I need. But when I place them in a sed command, sed fails. So I started building up from a smaller command. This is where I am now:

sed -r -e s/"<a name=\"/replacement/ <in >out

This works. But when I enter:

sed -r -e s/"<a name=\"[A-Za-z0-9 ?_.]+"/replacement/ <in >out

it fails with:

sed: can't read <in: Invalid argument
sed: can't read >out: Invalid argument

But the in file is really there. How can I get the regexp in the sed command? I have tried escaping/not escaping chars, but sed does not seem to accept it.