|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello,
First of all, thanks for your . After a few hours reading post about redirections, exec, ... I can not find a final solution to this problem: Given to programs, "foo" and "bar", the objective is a command who appends to the result of "foo" the result of "foo | cut -f 4 | bar". Append in the same way than "paste" does. That means: +--> cut --> bar --+ foo -->| +->paste +-----------------------+ Of course, without temporals ;-) Probably, I need tee to split the output of "foo" to two streams, but, how? Thanks a lot. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Jan 6, 7:48pm, tmp123 <tmp...@menta.net> wrote:
> Hello, > > First of all, thanks for your . > > After a few hours reading post about redirections, exec, ... I can not > find a final solution to this problem: > > Given to programs, "foo" and "bar", the objective is a command who > appends to the result of "foo" the result of "foo | cut -f 4 | bar". > Append in the same way than "paste" does. > > That means: > > +--> cut --> bar --+ > foo -->| +->paste > +-----------------------+ > > Of course, without temporals ;-) > > Probably, I need tee to split the output of "foo" to two streams, but, > how? > > Thanks a lot. Sorry, I've forgot an small clarification: The following command produces the expected result: mkfifo pp foo | tee pp | cut -f 3 | bar | paste - pp But an external fifo is need. Thanks again. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
tmp123 wrote:
> On Jan 6, 7:48 pm, tmp123 <tmp...@menta.net> wrote: >> >> First of all, thanks for your . >> >> After a few hours reading post about redirections, exec, ... I can not >> find a final solution to this problem: >> >> Given to programs, "foo" and "bar", the objective is a command who >> appends to the result of "foo" the result of "foo | cut -f 4 | bar". >> Append in the same way than "paste" does. >> >> That means: >> >> +--> cut --> bar --+ >> foo -->| +->paste >> +-----------------------+ >> >> Of course, without temporals ;-) >> >> Probably, I need tee to split the output of "foo" to two streams, but, >> how? >> >> Thanks a lot. > > Sorry, I've forgot an small clarification: > > The following command produces the expected result: > > mkfifo pp > foo | tee pp | cut -f 3 | bar | paste - pp [GNU bash] FOO="$(foo)" echo "$FOO" | cut -f 3- | bar| paste - <(echo "$FOO") -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your country. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Jan 6, 8:59 pm, Cyrus Kriticos <cyrus.kriti...@googlemail.com>
wrote: > tmp123 wrote: > > On Jan 6, 7:48 pm, tmp123 <tmp...@menta.net> wrote: > > >> First of all, thanks for your . > > >> After a few hours reading post about redirections, exec, ... I can not > >> find a final solution to this problem: > > >> Given to programs, "foo" and "bar", the objective is a command who > >> appends to the result of "foo" the result of "foo | cut -f 4 | bar". > >> Append in the same way than "paste" does. > > >> That means: > > >> +--> cut --> bar --+ > >> foo -->| +->paste > >> +-----------------------+ > > >> Of course, without temporals ;-) > > >> Probably, I need tee to split the output of "foo" to two streams, but, > >> how? > > >> Thanks a lot. > > > Sorry, I've forgot an small clarification: > > > The following command produces the expected result: > > > mkfifo pp > > foo | tee pp | cut -f 3 | bar | paste - pp > > [GNU bash] > > FOO="$(foo)" > echo "$FOO" | cut -f 3- | bar| paste - <(echo "$FOO") > Hello, Thanks a lot for your answer. "foo" is a never ending process. Is the solution valid with this restriction? Kind regards. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
tmp123 wrote:
> On Jan 6, 8:59 pm, Cyrus Kriticos <cyrus.kriti...@googlemail.com> > wrote: >> tmp123 wrote: >>> On Jan 6, 7:48 pm, tmp123 <tmp...@menta.net> wrote: >>>> First of all, thanks for your . >>>> After a few hours reading post about redirections, exec, ... I can not >>>> find a final solution to this problem: >>>> Given to programs, "foo" and "bar", the objective is a command who >>>> appends to the result of "foo" the result of "foo | cut -f 4 | bar". >>>> Append in the same way than "paste" does. >>>> That means: >>>> +--> cut --> bar --+ >>>> foo -->| +->paste >>>> +-----------------------+ >>>> Of course, without temporals ;-) >>>> Probably, I need tee to split the output of "foo" to two streams, but, >>>> how? >>>> Thanks a lot. >>> Sorry, I've forgot an small clarification: >>> The following command produces the expected result: >>> mkfifo pp >>> foo | tee pp | cut -f 3 | bar | paste - pp >> [GNU bash] >> >> FOO="$(foo)" >> echo "$FOO" | cut -f 3- | bar| paste - <(echo "$FOO") >> > > Hello, > > Thanks a lot for your answer. > > "foo" is a never ending process. Is the solution valid with this > restriction? No. -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your country. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Sun, 6 Jan 2008 10:59:31 -0800 (PST), tmp123 wrote:
[...] >> +--> cut --> bar --+ >> foo -->| +->paste >> +-----------------------+ >> >> Of course, without temporals ;-) >> >> Probably, I need tee to split the output of "foo" to two streams, but, >> how? >> >> Thanks a lot. > > Sorry, I've forgot an small clarification: > > The following command produces the expected result: > > mkfifo pp > foo | tee pp | cut -f 3 | bar | paste - pp > > But an external fifo is need. [...] You can't without a named pipe with usual Unix shells. You can probably do it in perl on systems with /dev/fd/<n> though. $^F = 0xffff; pipe AR, AW; pipe BR, BW; if (fork() == 0) { open STDOUT, ">&AW"; close AR; close BR; close AW; exec "foo | tee /dev/fd/" . fileno BW; } open STDIN, "<&AR"; close AR; close AW; close BW; exec "cut -f 3 | bar | paste - /dev/fd/" . fileno BR; -- Stephane |
|
![]() |
| Outils de la discussion | |
|
|