Have xargs pass a flag from stdin instead of command parameter
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Given an application, myApplication
, that streams lines to stdout
$ myApplication
flag1
flag2
flag3
How do I use xargs
to pass those values as flags to a command instead of passing them as parameters?
For example, the resulting invocations should be:
anotherApplication --flag "flag1" parameterNotFromXargs
anotherApplication --flag "flag2" parameterNotFromXargs
anotherApplication --flag "flag3" parameterNotFromXargs
My failed attempt using the -I
option produced the wrong output:
$ myApplication | xargs -L1 -I % echo "e: %"
e: %
e: %
e: %
pipe xargs
add a comment |Â
up vote
0
down vote
favorite
Given an application, myApplication
, that streams lines to stdout
$ myApplication
flag1
flag2
flag3
How do I use xargs
to pass those values as flags to a command instead of passing them as parameters?
For example, the resulting invocations should be:
anotherApplication --flag "flag1" parameterNotFromXargs
anotherApplication --flag "flag2" parameterNotFromXargs
anotherApplication --flag "flag3" parameterNotFromXargs
My failed attempt using the -I
option produced the wrong output:
$ myApplication | xargs -L1 -I % echo "e: %"
e: %
e: %
e: %
pipe xargs
1
What OS are you running? What version ofxargs
?
â ilkkachu
Sep 13 at 17:08
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Given an application, myApplication
, that streams lines to stdout
$ myApplication
flag1
flag2
flag3
How do I use xargs
to pass those values as flags to a command instead of passing them as parameters?
For example, the resulting invocations should be:
anotherApplication --flag "flag1" parameterNotFromXargs
anotherApplication --flag "flag2" parameterNotFromXargs
anotherApplication --flag "flag3" parameterNotFromXargs
My failed attempt using the -I
option produced the wrong output:
$ myApplication | xargs -L1 -I % echo "e: %"
e: %
e: %
e: %
pipe xargs
Given an application, myApplication
, that streams lines to stdout
$ myApplication
flag1
flag2
flag3
How do I use xargs
to pass those values as flags to a command instead of passing them as parameters?
For example, the resulting invocations should be:
anotherApplication --flag "flag1" parameterNotFromXargs
anotherApplication --flag "flag2" parameterNotFromXargs
anotherApplication --flag "flag3" parameterNotFromXargs
My failed attempt using the -I
option produced the wrong output:
$ myApplication | xargs -L1 -I % echo "e: %"
e: %
e: %
e: %
pipe xargs
pipe xargs
asked Sep 13 at 17:01
Ramon J Romero y Vigil
1256
1256
1
What OS are you running? What version ofxargs
?
â ilkkachu
Sep 13 at 17:08
add a comment |Â
1
What OS are you running? What version ofxargs
?
â ilkkachu
Sep 13 at 17:08
1
1
What OS are you running? What version of
xargs
?â ilkkachu
Sep 13 at 17:08
What OS are you running? What version of
xargs
?â ilkkachu
Sep 13 at 17:08
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
Unable to replicate:
$ echo -e "onentwonthree" | xargs -L1 -I% echo "I was told % times"
I was told one times
I was told two times
I was told three times
If myApplication
is returning its output on standard input, the above invocation of xargs
should work properly. If the output you are seeing is actually standard error, you need to redirect that to standard output with myApplication 2>&1
.
add a comment |Â
up vote
0
down vote
The easiest way is a script
#!/bin/sh
anotherApplication --flag "$1" parameterNotFromXargs
And call it with
myApplication | xargs -L1 ./myscript.sh
If you want to avoid the script, you can use give the command inline:
myApplication | xargs -L1 sh -c 'anotherApplication --flag "$1" parameterNotFromXargs' _
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Unable to replicate:
$ echo -e "onentwonthree" | xargs -L1 -I% echo "I was told % times"
I was told one times
I was told two times
I was told three times
If myApplication
is returning its output on standard input, the above invocation of xargs
should work properly. If the output you are seeing is actually standard error, you need to redirect that to standard output with myApplication 2>&1
.
add a comment |Â
up vote
0
down vote
Unable to replicate:
$ echo -e "onentwonthree" | xargs -L1 -I% echo "I was told % times"
I was told one times
I was told two times
I was told three times
If myApplication
is returning its output on standard input, the above invocation of xargs
should work properly. If the output you are seeing is actually standard error, you need to redirect that to standard output with myApplication 2>&1
.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Unable to replicate:
$ echo -e "onentwonthree" | xargs -L1 -I% echo "I was told % times"
I was told one times
I was told two times
I was told three times
If myApplication
is returning its output on standard input, the above invocation of xargs
should work properly. If the output you are seeing is actually standard error, you need to redirect that to standard output with myApplication 2>&1
.
Unable to replicate:
$ echo -e "onentwonthree" | xargs -L1 -I% echo "I was told % times"
I was told one times
I was told two times
I was told three times
If myApplication
is returning its output on standard input, the above invocation of xargs
should work properly. If the output you are seeing is actually standard error, you need to redirect that to standard output with myApplication 2>&1
.
answered Sep 13 at 17:06
DopeGhoti
41.3k55180
41.3k55180
add a comment |Â
add a comment |Â
up vote
0
down vote
The easiest way is a script
#!/bin/sh
anotherApplication --flag "$1" parameterNotFromXargs
And call it with
myApplication | xargs -L1 ./myscript.sh
If you want to avoid the script, you can use give the command inline:
myApplication | xargs -L1 sh -c 'anotherApplication --flag "$1" parameterNotFromXargs' _
add a comment |Â
up vote
0
down vote
The easiest way is a script
#!/bin/sh
anotherApplication --flag "$1" parameterNotFromXargs
And call it with
myApplication | xargs -L1 ./myscript.sh
If you want to avoid the script, you can use give the command inline:
myApplication | xargs -L1 sh -c 'anotherApplication --flag "$1" parameterNotFromXargs' _
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The easiest way is a script
#!/bin/sh
anotherApplication --flag "$1" parameterNotFromXargs
And call it with
myApplication | xargs -L1 ./myscript.sh
If you want to avoid the script, you can use give the command inline:
myApplication | xargs -L1 sh -c 'anotherApplication --flag "$1" parameterNotFromXargs' _
The easiest way is a script
#!/bin/sh
anotherApplication --flag "$1" parameterNotFromXargs
And call it with
myApplication | xargs -L1 ./myscript.sh
If you want to avoid the script, you can use give the command inline:
myApplication | xargs -L1 sh -c 'anotherApplication --flag "$1" parameterNotFromXargs' _
answered Sep 13 at 17:24
RalfFriedl
4,1251625
4,1251625
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468844%2fhave-xargs-pass-a-flag-from-stdin-instead-of-command-parameter%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
What OS are you running? What version of
xargs
?â ilkkachu
Sep 13 at 17:08