From: pk on
me at wrote:

>
> Hi,
>
> This works great in vim, :v,^New,d
> to delete all lines that do not begin with "New"
>
> Please tell me the sed equiv so I can put it
> into my #!/bin/sh script that I call from the
> command line with sed -f

/^New/!d

sed '/^New/!d'
From: pk on
me at wrote:

> Two different systems same result. What am I doing
> wrong?
>
> 159 % uname -a
> Linux XXXXXXXXXXXXXX 2.4.37.5 #1 SMP Mon Aug 17 10:15:36 PDT 2009 i686
> unknown 160 % sed '/^New/!d' list_raw | more
> d: Event not found.
> 161 %
>
>
> 40 % uname -a
> Linux XXXXXXXXXXXX 2.6.18-128.1.14.el5 #1 SMP Mon Jun 1 15:52:58 EDT 2009
> x86_64 x86_64 x86_64 GNU/Linux 41 % sed '/^New/!d' list_raw | more
> d: Event not found.
> 42 %

You are using a C shell, which doesn't like bangs ("!") even if they are in
single quotes.
To solve that, either put the sed code in its own file and run it with

sed -f code.sed list_raw

or disable history expansion (which, however, I don't know how is done with
a C shell).
From: Sidney Lambe on
On comp.unix.shell, pk <pk(a)pk.invalid> wrote:
> me at wrote:
>
>> Two different systems same result. What am I doing
>> wrong?
>>
>> 159 % uname -a
>> Linux XXXXXXXXXXXXXX 2.4.37.5 #1 SMP Mon Aug 17 10:15:36 PDT 2009 i686
>> unknown 160 % sed '/^New/!d' list_raw | more
>> d: Event not found.
>> 161 %
>>
>>
>> 40 % uname -a
>> Linux XXXXXXXXXXXX 2.6.18-128.1.14.el5 #1 SMP Mon Jun 1 15:52:58 EDT 2009
>> x86_64 x86_64 x86_64 GNU/Linux 41 % sed '/^New/!d' list_raw | more
>> d: Event not found.
>> 42 %
>

> You are using a C shell, which doesn't like bangs ("!") even if
> they are in single quotes. To solve that, either put the sed
> code in its own file and run it with
>
> sed -f code.sed list_raw
>
> or disable history expansion (which, however, I don't know how
> is done with a C shell).

Better yet, us bash, like almost everyone else.

I don't see why anyone bothers trying to help people using C shells.
Their choice of shells clearly establishes their lack of intelligence
and/or education.

Sid


From: Janis Papanagnou on
Sidney Lambe wrote:
> On comp.unix.shell, pk <pk(a)pk.invalid> wrote:
>> me at wrote:
>>
>>> Two different systems same result. What am I doing
>>> wrong?
>>>
>>> 159 % uname -a
>>> Linux XXXXXXXXXXXXXX 2.4.37.5 #1 SMP Mon Aug 17 10:15:36 PDT 2009 i686
>>> unknown 160 % sed '/^New/!d' list_raw | more
>>> d: Event not found.
>>> 161 %
>>>
>>>
>>> 40 % uname -a
>>> Linux XXXXXXXXXXXX 2.6.18-128.1.14.el5 #1 SMP Mon Jun 1 15:52:58 EDT 2009
>>> x86_64 x86_64 x86_64 GNU/Linux 41 % sed '/^New/!d' list_raw | more
>>> d: Event not found.
>>> 42 %
>
>> You are using a C shell, which doesn't like bangs ("!") even if
>> they are in single quotes. To solve that, either put the sed
>> code in its own file and run it with
>>
>> sed -f code.sed list_raw
>>
>> or disable history expansion (which, however, I don't know how
>> is done with a C shell).
>
> Better yet, us bash, like almost everyone else.

Hardly "almost everyone". Better yet, use any modern POSIX shell. Anyway.
A warning about C shell would certainly be appropriate; @OP: see standard
lecture http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

>
> I don't see why anyone bothers trying to help people using C shells.
> Their choice of shells clearly establishes their lack of intelligence
> and/or education.

That has rarely to do with intelligence in the first place; with newbies
it's most probably just ignorance. If you don't know better you cannot make
a better decision. Nothing that can't be fixed.

Janis

>
> Sid
>
>
From: Sidney Lambe on
On comp.unix.shell, Janis Papanagnou
<janis_papanagnou(a)hotmail.com> wrote: [delete]

>>> or disable history expansion (which, however, I don't know
>>> how is done with a C shell).
>>
>> Better yet, us bash, like almost everyone else.
>
> Hardly "almost everyone".

The overwhelming majority, unix or linux, in my experience.
It's the default shell on most linux distros and at least
some of the unix distros.

I think you hang out with more geeks than ordinary users :-)

> Better yet, use any modern POSIX shell. Anyway. A warning about
> C shell would certainly be appropriate; @OP: see standard
> lecture http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Sure is easier to use bash, which is a good as any of the other
POSIX shells and you are more likely to get help or be able
to give it.

>> I don't see why anyone bothers trying to help people using C
>> shells. Their choice of shells clearly establishes their lack
>> of intelligence and/or education.
>
> That has rarely to do with intelligence in the first place;
> with newbies it's most probably just ignorance. If you don't
> know better you cannot make a better decision. Nothing that
> can't be fixed.

Good way to look at it.

Sid