cygwin

cygwin

am 28.12.2007 00:14:43 von betoreyez

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

sed '0~10!d' file

Re: cygwin

am 28.12.2007 00:50:22 von Cyrus Kriticos

betoreyez@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.

Re: cygwin

am 28.12.2007 04:33:13 von Janis Papanagnou

betoreyez@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

Re: cygwin

am 28.12.2007 05:20:51 von Ed Morton

On 12/27/2007 5:50 PM, Cyrus Kriticos wrote:
> betoreyez@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.

Re: cygwin

am 28.12.2007 06:13:39 von Icarus Sparry

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

> On 12/27/2007 5:50 PM, Cyrus Kriticos wrote:
>> betoreyez@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.

Re: cygwin

am 28.12.2007 08:37:49 von Cyrus Kriticos

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.