I'm writing a Shell script to get a list of logged in users, i want to show a list like this one :
The user AAA is on tty3
The user BBB is on pts/0
Here's what i've written so far :
echo "The user " | who | awk -F ' ' '{print $1}' | echo " is on " | who | awk -F ' ' '{print $2}'
but in only shows the second column, i get this :
tty3
pts/0
Try doing this in single one
awk
statement:By doing that many piping, you are sending first one's input as another ones output. Hence you are losing previous data and at last only the output of
who | awk '{print $2}'
is coming out.