cygwin

why do this expresion to get every 10th line of a file dont work under
cygwin?

sed '0~10!d' file
betoreyez [ Fr, 28 Dezember 2007 00:14 ] [ ID #1894704 ]

Re: cygwin

betoreyez [at] gmail.com wrote:
> why do this expresion to get every 10th line of a file dont work under
> cygwin?
>
> sed '0~10!d' file

[GNU sed]

sed '10!d' file

--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
Cyrus Kriticos [ Fr, 28 Dezember 2007 00:50 ] [ ID #1894705 ]

Re: cygwin

betoreyez [at] gmail.com wrote:
> why do this expresion to get every 10th line of a file dont work under
> cygwin?

Sorry, cannot tell.

>
> sed '0~10!d' file

But in case you are satisfied with a workaround using awk...

awk '!(NR%10)' file


Janis
Janis Papanagnou [ Fr, 28 Dezember 2007 04:33 ] [ ID #1894708 ]

Re: cygwin

On 12/27/2007 5:50 PM, Cyrus Kriticos wrote:
> betoreyez [at] gmail.com wrote:
>
>>why do this expresion to get every 10th line of a file dont work under
>>cygwin?
>>
>>sed '0~10!d' file

I've never seen that syntax before so I've no clue. Sorry.

> [GNU sed]
>
> sed '10!d' file
>

That would print THE 10th line of a file (just as sed -n '10p' would), not EVERY
10th line.

For anything other than simple substitutions, sed should be avoided. For this
job, the awk syntax is clear and simple:

awk '!(NR%10)' file

Ed.
Ed Morton [ Fr, 28 Dezember 2007 05:20 ] [ ID #1894710 ]

Re: cygwin

On Thu, 27 Dec 2007 22:20:51 -0600, Ed Morton wrote:

> On 12/27/2007 5:50 PM, Cyrus Kriticos wrote:
>> betoreyez [at] gmail.com wrote:
>>
>>>why do this expresion to get every 10th line of a file dont work under
>>>cygwin?
>>>
>>>sed '0~10!d' file
>
> I've never seen that syntax before so I've no clue. Sorry.

>
> Ed.

It is a GNU sed'ism.
The "first~step" applies to every "step" lines, starting at "first".
I have never found the need to use it.
Icarus Sparry [ Fr, 28 Dezember 2007 06:13 ] [ ID #1894713 ]

Re: cygwin

Ed Morton wrote:
>
>> [GNU sed]
>>
>> sed '10!d' file
>
> That would print THE 10th line of a file (just as sed -n '10p' would), not EVERY
> 10th line.

Right.
The article was within 5 minutes withdrawn.


--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
Cyrus Kriticos [ Fr, 28 Dezember 2007 08:37 ] [ ID #1894716 ]
Linux » comp.unix.shell » cygwin

Vorheriges Thema: SED question: entering a blank line above eight character found
Nächstes Thema: bash source search path