linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doug Knight <doug.knight@uaf.edu>
To: "Mário Gamito" <gamito@gmail.com>
Cc: linux-admin@vger.kernel.org
Subject: Re: Removing lines - Part II
Date: Mon, 16 Apr 2007 13:36:15 -0800	[thread overview]
Message-ID: <4623EC4F.1060605@uaf.edu> (raw)
In-Reply-To: <CDE16182-5F7F-4232-A6AC-12C7D51E87A2@iicm.edu>

Mário,

I'll try to save you some time here.  The script below should do exactly
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="post-title"><a href="http://tuxvermelho\.blogspot\.com/2006/08/bourne-shell.html">Bourne Shell</a></h4>| b remove
: next
P
d
: remove
s|<h4 class="post-title"><a href="http://tuxvermelho\.blogspot\.com/2006/08/bourne-shell.html">Bourne Shell</a></h4>.*<p><a href="http://domain.com/2006/08/bourne-shell.html">Sáb, 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 things
don't work the way you expect them to.

Florian Klien wrote:
> On 16.04.2007, at 17:18, Mário Gamito wrote:
>> i do:
>> # sed -e 's/<h4 class="post-title"><a
>> href="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="post-title"><a
> href="http\:\/\/tuxvermelho.blogspot.com\/2006\/08\/bourne-shell.html">Bourne
> Shell<\/a><\/h4>/<!--/'
> 
> works for me. [1]
> 
> you could also substitute '/' with '$':
> sed -e 's$<h4 class="post-title"><a
> href="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.
> --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@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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2007-04-16 21:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-16 15:18 Removing lines - Part II Mário Gamito
2007-04-16 15:41 ` Florian Klien
2007-04-16 21:36   ` Doug Knight [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4623EC4F.1060605@uaf.edu \
    --to=doug.knight@uaf.edu \
    --cc=gamito@gmail.com \
    --cc=linux-admin@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).