Re: passing arguments within pipes
- From: Janis Papanagnou <Janis_Papanagnou@xxxxxxxxxxx>
- Date: Tue, 10 Apr 2007 01:16:20 +0200
Seb wrote:
Hi,
How should a 2nd and 3rd argument be passed to a function taking 3
arguments in a pipe? For example:
ls | gawk 'FNR == 3' | fun
Here fun takes 3 arguments and of course I would like its 1st one to be
what's passed from gawk. I'm obviously missing something in the docs
about how to do this. Thanks in advance for any suggestions.
Wait, wait - what are you trying to do here?
If fun takes _arguments_ you should not pipe in data (which are read by
fun through stdin and not through the argv list).
And you just read the third line (FNR==3) of the input stream (from ls),
is that intentional? Or do you rather want to select lines with 3 fields
(NF==3) to be passed to fun?
Shall fun read and process many "lines" of three argument data?
Some possibilities, depending on what you really want to do...
fun $( ls | gawk 'FNR == 3' ) ## BTW, equivalent to NR==3
fun $( ls | gawk 'NF == 3' )
ls | gawk 'NF == 3' | xargs -n2 fun
ls | gawk 'NF == 3' | while read -r a1 a2 a3; do fun $a1 $a2 $a3; done
Or let us know what you need.
Janis
.
Cheers,
- Follow-Ups:
- Re: passing arguments within pipes
- From: Seb
- Re: passing arguments within pipes
- References:
- passing arguments within pipes
- From: Seb
- passing arguments within pipes
- Prev by Date: passing arguments within pipes
- Next by Date: Re: passing arguments within pipes
- Previous by thread: passing arguments within pipes
- Next by thread: Re: passing arguments within pipes
- Index(es):
Relevant Pages
|