Unix Programming - Pipe Problem

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2005 > Pipe Problem





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 Pipe Problem
Diane

2005-10-26, 6:01 pm

Could anyone explain me please why when I am trying to pipe the egrep
command it doesn't work? I tried the following:

egrep '[a-z].*roy' filename | egrep '.*[ ].*[a-z].*$'

Thanks!

Ralf Fassel

2005-10-26, 6:01 pm

* "Diane" <froufrou_00@hotmail.com>
| Could anyone explain me please why when I am trying to pipe the
| egrep command it doesn't work?

What was the error message?

R'
Giorgos Keramidas

2005-10-26, 6:01 pm

"Diane" <froufrou_00@hotmail.com> writes:
> Could anyone explain me please why when I am trying to pipe the egrep
> command it doesn't work? I tried the following:
>
> egrep '[a-z].*roy' filename | egrep '.*[ ].*[a-z].*$'


It seems to work fine here:

% flame:/home/keramida$ echo 'Ryan McIlroy' > /tmp/foo
% flame:/home/keramida$ egrep '[a-z].*roy' /tmp/foo | egrep '.*[ ].*[a-z].*$'
% Ryan McIlroy
% flame:/home/keramida$

What do you mean by ``it doesn't work''?

- Giorgos

Diane

2005-10-26, 6:01 pm

It executes only the one part of the pipe


Giorgos Keramidas wrote:
> "Diane" <froufrou_00@hotmail.com> writes:
>
> It seems to work fine here:
>
> % flame:/home/keramida$ echo 'Ryan McIlroy' > /tmp/foo
> % flame:/home/keramida$ egrep '[a-z].*roy' /tmp/foo | egrep '.*[ ].*[a-z].*$'
> % Ryan McIlroy
> % flame:/home/keramida$
>
> What do you mean by ``it doesn't work''?
>
> - Giorgos


Giorgos Keramidas

2005-10-26, 6:01 pm

"Diane" <froufrou_00@hotmail.com> writes:
> Giorgos Keramidas wrote:
>
> It executes only the one part of the pipe


You didn't use double '|' characters by any chance, right?
This:

egrep '[a-z].*roy' filename || egrep '.*[ ].*[a-z].*$'

is very different from the one quoted above.

What shell are you using anyway?

Barry Margolin

2005-10-27, 2:48 am

In article <1130344112.777745.67430@f14g2000cwb.googlegroups.com>,
"Diane" <froufrou_00@hotmail.com> wrote:

> Could anyone explain me please why when I am trying to pipe the egrep
> command it doesn't work? I tried the following:
>
> egrep '[a-z].*roy' filename | egrep '.*[ ].*[a-z].*$'


Works find for me:

barmar $ cat test.data
abcroydef
abcdefg hijkl
groy xxx
barmar $ egrep '[a-z].*roy' test.data | egrep '.*[ ].*[a-z].*$'
groy xxx
barmar $

BTW, you don't need the '.*' at the beginning of the second regexp, the
".*$' at the end of it, nor do you need [] around the space. The second
command in the pipe is equivalent to:

egrep ' .*[a-z]'

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com