9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] sed Q
@ 2010-03-05  7:17 Peter A. Cejchan
  2010-03-05  8:17 ` Rudolf Sykora
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Peter A. Cejchan @ 2010-03-05  7:17 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

hi,
i would like to append next line if current ends with ']'
however

     sed '/\]$/N' foo

does not work...
++pac



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sed Q
  2010-03-05  7:17 [9fans] sed Q Peter A. Cejchan
@ 2010-03-05  8:17 ` Rudolf Sykora
  2010-03-05  8:40   ` Peter A. Cejchan
  2010-03-05  8:19 ` Rudolf Sykora
  2010-03-05  8:41 ` roger peppe
  2 siblings, 1 reply; 6+ messages in thread
From: Rudolf Sykora @ 2010-03-05  8:17 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 5 March 2010 08:17, Peter A. Cejchan <tyapca7@gmail.com> wrote:
> hi,
> i would like to append next line if current ends with ']'
> however
>
>     sed '/\]$/N' foo
>
> does not work...
> ++pac

I quickly tried
sed -e '/]$/N' -e 's/\n//'
in linux and it did it...
But maybe you must adjust it a bit

Ruda



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sed Q
  2010-03-05  7:17 [9fans] sed Q Peter A. Cejchan
  2010-03-05  8:17 ` Rudolf Sykora
@ 2010-03-05  8:19 ` Rudolf Sykora
  2010-03-05  8:41 ` roger peppe
  2 siblings, 0 replies; 6+ messages in thread
From: Rudolf Sykora @ 2010-03-05  8:19 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 5 March 2010 08:17, Peter A. Cejchan <tyapca7@gmail.com> wrote:
> hi,
> i would like to append next line if current ends with ']'
> however
>
>     sed '/\]$/N' foo
>
> does not work...
> ++pac

(I think N just adds the next line to the buffer and you have to
manually get rid of the special newline in the middle.)
Ruda



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sed Q
  2010-03-05  8:17 ` Rudolf Sykora
@ 2010-03-05  8:40   ` Peter A. Cejchan
  0 siblings, 0 replies; 6+ messages in thread
From: Peter A. Cejchan @ 2010-03-05  8:40 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> sed -e '/]$/N' -e 's/\n//'

Thanks, it works, at least wit 9sed on linux, will try on plan9 native
in a while...
Diky,
Petr.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sed Q
  2010-03-05  7:17 [9fans] sed Q Peter A. Cejchan
  2010-03-05  8:17 ` Rudolf Sykora
  2010-03-05  8:19 ` Rudolf Sykora
@ 2010-03-05  8:41 ` roger peppe
  2010-03-05  8:47   ` Peter A. Cejchan
  2 siblings, 1 reply; 6+ messages in thread
From: roger peppe @ 2010-03-05  8:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

i don't quite see what you're trying to do here.
it's doing what you're asking - but that's a no-op,
because N includes an embedded newline.

you can do: sed -e '/]/N' -e 's/\n//'
if you want to join the lines.

or something like this:
sed ':x
	/]$/{
		N
		s/\n/ /
		t x
	}'

if you want it to work for more than two consecutive
lines.

On 5 March 2010 07:17, Peter A. Cejchan <tyapca7@gmail.com> wrote:
> hi,
> i would like to append next line if current ends with ']'
> however
>
>     sed '/\]$/N' foo
>
> does not work...
> ++pac
>
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sed Q
  2010-03-05  8:41 ` roger peppe
@ 2010-03-05  8:47   ` Peter A. Cejchan
  0 siblings, 0 replies; 6+ messages in thread
From: Peter A. Cejchan @ 2010-03-05  8:47 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> it's doing what you're asking - but that's a no-op,
> because N includes an embedded newline.

thanks, need more experience, sorry for annoying,
++pac



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-03-05  8:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-05  7:17 [9fans] sed Q Peter A. Cejchan
2010-03-05  8:17 ` Rudolf Sykora
2010-03-05  8:40   ` Peter A. Cejchan
2010-03-05  8:19 ` Rudolf Sykora
2010-03-05  8:41 ` roger peppe
2010-03-05  8:47   ` Peter A. Cejchan

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).