Removing lines - Part II
Hi,
I've been doing what i've been told.
Searching google for help.
I want to replace this line:
<h4 class=3D"post-title"><a
href=3D"http://tuxvermelho.blogspot.com/2006/08/bourne-shell .html">Bour=
ne
Shell</a></h4>
for:
<!--
i do:
# sed -e 's/<h4 class=3D"post-title"><a
href=3D"http://tuxvermelho.blogspot.com/2006/08/bourne-shell .html">Bour=
ne
Shell</a></h4>/<!--/' < index.html
but get an error:
sed: -e expression #1, char 42: Unknown option to `s
Can someone help me, please ?
Any help would be appreciated.
Warm Regards
--
:wq! M=E1rio Gamito
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Removing lines - Part II
On 16.04.2007, at 17:18, M=E1rio Gamito wrote:
> i do:
> # sed -e 's/<h4 class=3D"post-title"><a
> href=3D"http://tuxvermelho.blogspot.com/2006/08/bourne-
> shell.html">Bourne
> Shell</a></h4>/<!--/' < index.html
well you should escape the '/', like:
sed -e 's/<h4 class=3D"post-title"><a href=3D"http\:\/\/
tuxvermelho.blogspot.com\/2006\/08\/bourne-shell.html">Bourn e Shell<\/
a><\/h4>/<!--/'
works for me. [1]
you could also substitute '/' with '$':
sed -e 's$<h4 class=3D"post-title"><a href=3D"http\://
tuxvermelho.blogspot.com/2006/08/bourne-shell.html">Bourne Shell</a></
h4>$<!--$'
then you don't need to escape anything except there would be a '$' in
the text....
hth
florian
[1]: $ sed --version
GNU sed version 4.1.4
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There
is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE,
to the extent permitted by law.
--
=46lorian Klien
student of Telematics, tutor for 'Introduction to Structured
Programming' and 'Software Development Practical Exercises'
at Graz university of technology.
"When in doubt, use brute force.", Ken Thompson
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Removing lines - Part II
M=E1rio,
I'll try to save you some time here. The script below should do exactl=
y
what you asked for help with. However, as you can see, sed is a
``write only'' language. If you're going to be maintaining this code, =
I
would suggest rewriting it in something a bit more readable such as awk=
,
or perl.
-------- START OF FILE --------
\|<h4 class=3D"post-title"><a href=3D"http://tuxvermelho\.blogspot\.com=
/2006/08/bourne-shell.html">Bourne Shell</a></h4>| b remove
: next
P
d
: remove
s|<h4 class=3D"post-title"><a href=3D"http://tuxvermelho\.blogspot\.com=
/2006/08/bourne-shell.html">Bourne Shell</a></h4>.*<p><a href=3D"http:/=
/domain.com/2006/08/bourne-shell.html">S=C3=A1b, 14 Abr 2007 12:31:07</=
a></p>||
t next
N
b remove
-------- END OF FILE --------
If you want to fit the script on one line, replace the line feeds with =
semicolons (``;'').
Doug Knight
P.S. I would advise against making a habit of using ``$'' or any other
character that has special meanings in regular expressions as a
substitution delimiter, unless you enjoy driving yourself crazy when th=
ings
don't work the way you expect them to.
=46lorian Klien wrote:
> On 16.04.2007, at 17:18, M=E1rio Gamito wrote:
>> i do:
>> # sed -e 's/<h4 class=3D"post-title"><a
>> href=3D"http://tuxvermelho.blogspot.com/2006/08/bourne-shell .html">B=
ourne
>> Shell</a></h4>/<!--/' < index.html
>
> well you should escape the '/', like:
> sed -e 's/<h4 class=3D"post-title"><a
> href=3D"http\:\/\/tuxvermelho.blogspot.com\/2006\/08\/bourne -shell.ht=
ml">Bourne
> Shell<\/a><\/h4>/<!--/'
>
> works for me. [1]
>
> you could also substitute '/' with '$':
> sed -e 's$<h4 class=3D"post-title"><a
> href=3D"http\://tuxvermelho.blogspot.com/2006/08/bourne-shel l.html">B=
ourne
> Shell</a></h4>$<!--$'
>
> then you don't need to escape anything except there would be a '$' in
> the text....
>
> hth
> florian
> [1]: $ sed --version
> GNU sed version 4.1.4
> Copyright (C) 2003 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There =
is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PU=
RPOSE,
> to the extent permitted by law.
> --Florian Klien
> student of Telematics, tutor for 'Introduction to Structured
> Programming' and 'Software Development Practical Exercises'
> at Graz university of technology.
> "When in doubt, use brute force.", Ken Thompson
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-admin=
" in
> the body of a message to majordomo [at] vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html