From: Sidney Lambe on
Ed Morton <mortonspam(a)gmail.com> wrote:
> On Sep 25, 12:59=A0pm, vjp2...(a)at.BioStrategist.dot.dot.com wrote:
>> I have a file that has a series of lists
>>
>> (qqq)
>> aaa 111
>> bbb 222
>>
>> and I want to make it look like
>>
>> aaa 111 (qqq)
>> bbb 222 (qqq)
>>
>> where some lists have only aaa
>> and some have both or more but all end in a number
>>
>> the list should be considered ended if another (qqq) shows up
>>
>
> sed is a great tool for simple substitutions on a single line, for
> anything else use awk, perl, etc.

Most experts in this area would disagree with that statement,

That's why, for example, OREILLY published a book called
"Sed & Awk".

They devote half a book to an application and gave it equal
billing with awk.

It obviously does a lot more than simple substutions.

>
> awk '/^\(/{ h=3D$0;next } { print $0,h }' file
>
> Ed.


Ed Morton is a neurotic who hates sed and doesn't have the
integrity to keep his ignorant and prejudiced ideas on the
subject to himself.

This makes it very difficult to trust what he says about
anything to do with computers.

What other irrational prejudices does he have that are
so extreme that he will regularly post lies like the
above?

Sid




From: Sidney Lambe on
vjp2.at[delete] wrote:
> I have a file that has a series of lists
>
> (qqq)
> aaa 111
> bbb 222
>
> and I want to make it look like
>
> aaa 111 (qqq)
> bbb 222 (qqq)
>
>
> where some lists have only aaa
> and some have both or more but all end in a number
>
> the list should be considered ended if another (qqq) shows up
>
>

[delete sig]

I was gonna post a sed solution, but that oversized sig lacking
a delimiter with its promotion of violent solutions to problems
has changed my mind. You don't help people like this. You
throw them out of your country or put them in jail or send
them to a mental institution.

Sid


From: sharma__r on
On Sep 25, 10:59 pm, vjp2...(a)at.BioStrategist.dot.dot.com wrote:
> I have a file that has a series of lists
>
> (qqq)
> aaa 111
> bbb 222
>
> and I want to make it look like
>
> aaa 111 (qqq)
> bbb 222 (qqq)
>
> where some lists have only aaa
> and some have both or more but all end in a number
>
> the list should be considered ended if another (qqq) shows up
>

Assuming you are typing on a bourne or a bourne-based shell command
line (e.g., bash), then do this:

sed -e '
/^([^)]*)/{
h; # remember the (qqq) part
d
}

/ [1-9][0-9]*$/{
G; # strap the (qqq) part to the list
s/\n/ /
}
' yourfile

For other shells you could put the sed commands into a file & then
invoke sed with the -f option.

--Rakesh
From: Loki Harfagr on
Sat, 26 Sep 2009 06:09:45 +0200, Sidney Lambe flubbered :

> What he would do if he was a rational person would be to respect
> people's choices and when he sees a subject with "sed" in it to just go
> off in a corner somewhere and sulk rather than harassing them.

so much for praising googmail googroups posts then ,->
seems you'll have to control-alt-shift your paradigm then...
From: Ben Bacarisse on
Sidney Lambe <sidneylambe(a)nospam.invalid> writes:
<snip>
> Ed, no one needs your permission or approval to use
> sed.

No indeed, but some people need help because it is not always obvious
how to do something in sed.

> They can use it if they want to.
>
> If you don't like it you can eat sh*t.

I think you'd do more good by leaving the insults to one side and
posting a sed solution. I tried to find one but gave up after a few
minutes. The more neat sed examples I see the better.

--
Ben.