From: Jeff King <peff@peff.net>
To: Git Mailing List <git@vger.kernel.org>
Subject: Re: Help a sed noob
Date: Sat, 4 Aug 2007 08:40:05 -0400 [thread overview]
Message-ID: <20070804124005.GA15334@sigill.intra.peff.net> (raw)
In-Reply-To: <20070804121811.GA1605@lapse.madduck.net>
On Sat, Aug 04, 2007 at 02:18:11PM +0200, martin f krafft wrote:
> The behaviour is absolutely unclear from the manpage and defies my
> logic. Can you elaborate a bit, even though this is off-topic?
The original sed code in question was:
sed -ne '/^URL: */{
s///p
q
}' "$GIT_DIR/remotes/$1"
There are a few things to note:
1. -n means "do not print lines by default"
2. sed addresses consist of an address (in this case a regex meaning
"do this for lines that match the regex") and a command
3. The braces start a set of commands, so that for lines matching the
address, we do all of the commands.
4. An empty matching portion for a regex means "use the last regex".
So this script comes down to:
- don't write any lines except the ones we match
- find a line that starts with URL:
- replace the URL: part with nothing
- print the result
- quit
It could be more simply written as:
sed -ne 's/^URL: *//pq'
which uses the substitution as an address, but I don't know whether that
was allowed in the original sed.
-Peff
prev parent reply other threads:[~2007-08-04 12:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-03 23:22 Help a sed noob Nguyen Thai Ngoc Duy
2007-08-03 23:38 ` Junio C Hamano
2007-08-04 0:06 ` Nguyen Thai Ngoc Duy
2007-08-03 23:40 ` René Scharfe
2007-08-04 10:31 ` martin f krafft
2007-08-04 11:50 ` Jeff King
2007-08-04 12:18 ` martin f krafft
2007-08-04 12:26 ` Simon 'corecode' Schubert
2007-08-04 13:56 ` martin f krafft
2007-08-04 14:06 ` David Kastrup
2007-08-04 12:40 ` Jeff King [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=20070804124005.GA15334@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@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 NNTP newsgroup(s).