Friday, December 02, 2022

redirection puzzle

Dear list,


I needed to show the stdout of a command as well as pass
it to another command's stdin. This works:

odin:~$ echo 1 | tee /dev/stderr | sed 's/1/2/'
1
2
odin:~$

and this works, too:

odin:~$ echo 1 | tee /dev/ttyp8 | sed 's/1/2/'
1
2
odin:~$

where /dev/ttyp8 is the result of the tty command:

odin:~$ tty
/dev/ttyp8
odin:~$

but this does not work:

odin:~$ echo 1 | tee $(tty) | sed 's/1/2/'
2
odin:~$

I do not understand why...

Thanks for any comments (and sorry for such a trivial
question).


Best regards,
Ruda

No comments:

Post a Comment