Re: Append only first instance with sed?

From: Kenny McCormack (gazelle_at_yin.interaccess.com)
Date: 07/01/04


Date: Wed, 30 Jun 2004 22:48:16 GMT

In article <aTFEc.452$R36.60@newsread2.news.pas.earthlink.net>,
Alan Connor <xxxx@yyy.zzz> wrote:
>On Wed, 30 Jun 2004 20:24:38 GMT, Kenny McCormack <gazelle@yin.interaccess.com> wrote:
>>
>>
>> In article <slrnce5n30.180.stephane.chazelas@spam.is.invalid>,
>> Stephane CHAZELAS <this.address@is.invalid> wrote:
>>>2004-06-30, 10:24(-05), glitch@mlh.net:
>>>> I'm trying to do an append with sed. My problem is that the pattern
>>>> that I'm matching occurs more than once in the file. I only want to
>>>> append the first time the pattern is found. Here is what I have:
>>>>
>>>> sed -e "1,/^Listen/a\\
>>>> Listen $WWWIP:443
>>>> " </usr/local/apache/conf/ssl.conf >/tmp/ssl.conf.$$
>>>[...]
>>>
>>>Use awk instead:
>>
>> This is the best advice I've seen posted in comp.unix.shell in quite some
>> time. Most of the time, if you try to use sed to solve a problem, all
>> you're doing is demonstrating to the world that you are into pain.
>>
>
>Says someone who doesn't know sed. For someone who didn't know awk,
>using IT would be a pain.
>
>DUH
>
>In this case, the OP *obviously* doesn't know either one of them.

Thanks for making my point. The fact is that a lot of newbies don't really
know either, but get involved in using sed, because it is decepively simple
to use (for very simple tasks).

I.e., the only excuse for using sed for complex tasks is because one
already knows it well (in which case, there is no hope for you...)



Relevant Pages

  • Re: Append only first instance with sed?
    ... Alan Connor wrote: ... >> This is the best advice I've seen posted in comp.unix.shell in quite some ... >> you're doing is demonstrating to the world that you are into pain. ... Chuck Demas ...
    (comp.unix.shell)
  • An update
    ... After getting some valuable advice from many of you here in this usenet ... group I scheduled an emergency appointment with my Rheumatologist. ... the pain and stiffness. ... First of all he scheduled a CT scan for my stomach, ...
    (alt.support.arthritis)
  • Re: should i accept compensation?
    ... How long will you be in pain from your neck as a result? ... if you can't do your job and are still in a neck brace in 18mo ... Get some specialist advice. ... help with specialist legal advice, ...
    (uk.legal)
  • Re: carpal tunnel surgery advise please...
    ... procedure (there was a little pain but hey, I had to play!) The only thing I ... tedious, pinball play is zero, and now work from home... ... obviously 9/10 you will be advised for surgery. ... Seek advice from experts, Your Life and Your Health are far more ...
    (rec.games.pinball)
  • Re: [NPP] That age old question -- what to wear?
    ... so carry Fatty as a swap ... Thanks for the advice. ... I mostly weilded Pain and equipped Ulmo as useful. ...
    (rec.games.roguelike.angband)