Using process substitution, only send stderr to process
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have this:
exec > >( while read line; do echo " stdout: $line"; done )
exec 2> >( while read line; do echo " stderr: $line"; done )
echo "rolo"
>&2 echo "cholo"
if you run that script, it results in the following output:
stdout: rolo
stdout: stderr: cholo
how can I only send stderr to the second process substitution line?
I don't get it.
I don't understand why this is happening:
stdout: rolo
stdout: stderr: cholo # what lol
bash shell-script shell process-substitution
add a comment |Â
up vote
0
down vote
favorite
I have this:
exec > >( while read line; do echo " stdout: $line"; done )
exec 2> >( while read line; do echo " stderr: $line"; done )
echo "rolo"
>&2 echo "cholo"
if you run that script, it results in the following output:
stdout: rolo
stdout: stderr: cholo
how can I only send stderr to the second process substitution line?
I don't get it.
I don't understand why this is happening:
stdout: rolo
stdout: stderr: cholo # what lol
bash shell-script shell process-substitution
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have this:
exec > >( while read line; do echo " stdout: $line"; done )
exec 2> >( while read line; do echo " stderr: $line"; done )
echo "rolo"
>&2 echo "cholo"
if you run that script, it results in the following output:
stdout: rolo
stdout: stderr: cholo
how can I only send stderr to the second process substitution line?
I don't get it.
I don't understand why this is happening:
stdout: rolo
stdout: stderr: cholo # what lol
bash shell-script shell process-substitution
I have this:
exec > >( while read line; do echo " stdout: $line"; done )
exec 2> >( while read line; do echo " stderr: $line"; done )
echo "rolo"
>&2 echo "cholo"
if you run that script, it results in the following output:
stdout: rolo
stdout: stderr: cholo
how can I only send stderr to the second process substitution line?
I don't get it.
I don't understand why this is happening:
stdout: rolo
stdout: stderr: cholo # what lol
bash shell-script shell process-substitution
edited May 8 at 4:55
asked May 8 at 4:48
Alexander Mills
1,885929
1,885929
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You set up the redirections in the wrong order. The standard output of the second process substitution (which prefixes with stderr:
) has its standard output prefixed by the first process substitution, because it was run afterwards.
Try this instead:
exec 2> >( while read line; do echo " stderr: $line"; done )
exec > >( while read line; do echo " stdout: $line"; done )
echo "rolo"
echo "cholo" >&2
This outputs
stderr: cholo
stdout: rolo
which is what I presume you want.
Comments are not for extended discussion; this conversation has been moved to chat.
â terdonâ¦
May 8 at 16:37
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You set up the redirections in the wrong order. The standard output of the second process substitution (which prefixes with stderr:
) has its standard output prefixed by the first process substitution, because it was run afterwards.
Try this instead:
exec 2> >( while read line; do echo " stderr: $line"; done )
exec > >( while read line; do echo " stdout: $line"; done )
echo "rolo"
echo "cholo" >&2
This outputs
stderr: cholo
stdout: rolo
which is what I presume you want.
Comments are not for extended discussion; this conversation has been moved to chat.
â terdonâ¦
May 8 at 16:37
add a comment |Â
up vote
3
down vote
accepted
You set up the redirections in the wrong order. The standard output of the second process substitution (which prefixes with stderr:
) has its standard output prefixed by the first process substitution, because it was run afterwards.
Try this instead:
exec 2> >( while read line; do echo " stderr: $line"; done )
exec > >( while read line; do echo " stdout: $line"; done )
echo "rolo"
echo "cholo" >&2
This outputs
stderr: cholo
stdout: rolo
which is what I presume you want.
Comments are not for extended discussion; this conversation has been moved to chat.
â terdonâ¦
May 8 at 16:37
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You set up the redirections in the wrong order. The standard output of the second process substitution (which prefixes with stderr:
) has its standard output prefixed by the first process substitution, because it was run afterwards.
Try this instead:
exec 2> >( while read line; do echo " stderr: $line"; done )
exec > >( while read line; do echo " stdout: $line"; done )
echo "rolo"
echo "cholo" >&2
This outputs
stderr: cholo
stdout: rolo
which is what I presume you want.
You set up the redirections in the wrong order. The standard output of the second process substitution (which prefixes with stderr:
) has its standard output prefixed by the first process substitution, because it was run afterwards.
Try this instead:
exec 2> >( while read line; do echo " stderr: $line"; done )
exec > >( while read line; do echo " stdout: $line"; done )
echo "rolo"
echo "cholo" >&2
This outputs
stderr: cholo
stdout: rolo
which is what I presume you want.
answered May 8 at 5:06
Kusalananda
102k13199315
102k13199315
Comments are not for extended discussion; this conversation has been moved to chat.
â terdonâ¦
May 8 at 16:37
add a comment |Â
Comments are not for extended discussion; this conversation has been moved to chat.
â terdonâ¦
May 8 at 16:37
Comments are not for extended discussion; this conversation has been moved to chat.
â terdonâ¦
May 8 at 16:37
Comments are not for extended discussion; this conversation has been moved to chat.
â terdonâ¦
May 8 at 16:37
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%2f442461%2fusing-process-substitution-only-send-stderr-to-process%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