As a compound command, a while loop can also accept the output of another command as input, using a pipe. For example, to pass the output of who -T to the loop as input, to print only the terminal names for active users on the system, we might write:
who -T | while read -r username state terminal _ ; do printf '%s\n' "$terminal" done