can sed pattern contain '<' & '>' characters or not?

can sed pattern contain '<' & '>' characters or not?

Post by RamaKrishna Narl » Sun, 25 Sep 2005 20:03:40



Hi,

I have a set of html files. I want to replace all of <H1> tags with
<H2> tags.

So, am trying with sed command like
sed 's/<H1>/<H2>/' <oldfile.html >newfile.html

But it is giving me error saying that "sed: newline or end of file
found in pattern".

I don't want to replace H2 with H1. I want it like <H1> -> <H2>.
Is this possible with sed or not?

Thanks in advance
- Ramakrishna.

 
 
 

can sed pattern contain '<' & '>' characters or not?

Post by Bill Marcu » Sun, 25 Sep 2005 23:21:25


On 24 Sep 2005 04:03:40 -0700, RamaKrishna Narla

> Hi,

> I have a set of html files. I want to replace all of <H1> tags with
><H2> tags.

> So, am trying with sed command like
> sed 's/<H1>/<H2>/' <oldfile.html >newfile.html

Is that the exact command?  It should work.

--
I have discovered that all human evil comes from this, man's being unable
to sit still in a room.
                -- Blaise Pascal

 
 
 

can sed pattern contain '<' & '>' characters or not?

Post by Joe Use » Mon, 26 Sep 2005 01:04:31



> I have a set of html files. I want to replace all of <H1> tags with <H2>
> tags.

> So, am trying with sed command like
> sed 's/<H1>/<H2>/' <oldfile.html >newfile.html

> But it is giving me error saying that "sed: newline or end of file found
> in pattern".

Look:

sed 's/<H1>/<H2>/g' <<<$'<H1><H3><H1>'
<H2><H3><H2>

--
        It's not the plan I want.  It's the planning.

                -- Dwight Eisenhower

 
 
 

can sed pattern contain '<' & '>' characters or not?

Post by Enrique Perez-Terro » Mon, 26 Sep 2005 20:27:24




Quote:> Hi,

> I have a set of html files. I want to replace all of <H1> tags with
> <H2> tags.

> So, am trying with sed command like
> sed 's/<H1>/<H2>/' <oldfile.html >newfile.html

> But it is giving me error saying that "sed: newline or end of file
> found in pattern".

> I don't want to replace H2 with H1. I want it like <H1> -> <H2>.
> Is this possible with sed or not?

I don't know what to think of this, are you trying on a computer with
a different sed, or a different shell with different quoting rules,
or... ?

At least, for me this works:

   $ echo "trallala <h1> blah" | sed -e 's/<h1>/<h2>/'
   trallala <h2> blah

Perhaps you are just being taxed by King FingerTrouble and
his wife, Queen ChessBlindness?  We have all been, dearly.

-Enrique

 
 
 

can sed pattern contain '<' & '>' characters or not?

Post by Kenny McCorma » Tue, 27 Sep 2005 00:59:38




>On 24 Sep 2005 04:03:40 -0700, RamaKrishna Narla

>> Hi,

>> I have a set of html files. I want to replace all of <H1> tags with
>><H2> tags.

>> So, am trying with sed command like
>> sed 's/<H1>/<H2>/' <oldfile.html >newfile.html

>Is that the exact command?  It should work.

Sounds like the OP is on DOS/Windows.

Why he posted to a Unix group is a good question.

 
 
 

1. Passing argument containing <SPACE> in a script using 'sed'

I want to automatically replace for example "cat" by "big dog" in the file "myfile"

first I have
----
$ cat myfile
There is a cat in the kitchen
$
-----

So if I run a script like

----
$ cat go
sed -e 's/cat/big dog/' myfile
$ go
There is a big dog in the kitchen
$
----
I want now to have "big dog" taken from argument so
----
$ cat go2
sed -e 's/cat/'$1'/' myfile
$ go2 "big dog"
sed: Function s/cat/big cannot be parsed.
$ go2 "dog"
There is a dog in the kitchen
$
----
So what's wrong with <SPACE>. Could someone help me please?

Thanks a lot

--
Tuyet Tram DANG NGOC
DESS IRS (Ingenierie Reseaux et Systeme) -  Universite de Versailles

http://www.ens-info.uvsq.fr:8000/~dntt/index.html

2. Trouble in using 3C509 Nics

3. ksh ': >a >b' -vs- '>a >b' re speed

4. hardware detection commands in Linux

5. Request headers - 'Reload', <SHIFT>+'Reload'

6. Is it possible to control what ports BIND uses?

7. Implement '<'or '>' system commands in C

8. Installing HD

9. PROBLEM: 'sed' script 's/^ /\n/' not working properly

10. rsh machine -n 'command >&/dev/null </dev/null &'

11. sed -e 's/\'a\'/\';\'/' ?

12. Simple 'sed', 'awk', 'cut' problem

13. Using sed with \ and ' and <CR><LF>