Usually, xargs is used to output one command as an option to another command. For example:
$ cat command1 #!/bin/sh echo "one" echo "two" echo "three" $ cat command2 #!/bin/sh printf '1 = %s\n' "$1" $ ./command1 | xargs -n 1 ./command2 1 = one 1 = two 1 = three $
But ... as long as it was your question, this is not what you really want to know.
If you don't mind storing your tty in a variable, you can use the change bash variable for your substitution:
$ tty=`tty`; who | grep -w "${tty
(You want to use -w because if you are on pts / 6 you should not see pts / 60 logins.)
You are limited to this in the variable, because if you try to put the tty command in a channel, it thinks that it no longer works with the terminal.
$ true | echo `tty | sed 's:/dev/::'` not a tty $
Note that nothing in this answer yet applies to bash. Since you are using bash, another way to solve this problem is to use process substitution. For example, while this does not work:
$ who | grep "$(tty | sed 's:/dev/::')"
It does:
$ grep $(tty | sed 's:/dev/::') < <(who)
ghoti
source share