Unix Shell - cygwin

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > December 2007 > cygwin





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author cygwin
betoreyez@gmail.com

2007-12-27, 7:25 pm

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

sed '0~10!d' file
Cyrus Kriticos

2007-12-27, 7:25 pm

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.
Janis Papanagnou

2007-12-28, 1:36 am

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
Ed Morton

2007-12-28, 1:36 am



On 12/27/2007 5:50 PM, Cyrus Kriticos wrote:
> betoreyez@gmail.com wrote:
>

I've never seen that syntax before so I've no clue. Sorry.
[vbcol=seagreen]
> [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.

Icarus Sparry

2007-12-28, 1:36 am

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

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

2007-12-28, 7:31 am

Ed Morton wrote:
>
>
> 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.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com