Linux pipe and tee with who

Digging in to shell. What i find is may be useful for you guys.

1. Redirection (>) routes the output to the files while pipes ( | ) routes the outputs to other program. But tee command do the both

Problem what i was trying to solve.

Reference: Unix Shell Programming by Yashawant Kanetkar

Output of who Command should be sorted and displayed on the screen along with the total number of users. The same output except the total number of users should also be sorted in file file1

The Answer is :

who | sort | tee /dev/pts/0 file1 | wc -l

/dev/pts/0 is my current tty

May be helpful for you.

Have Fun!


Advertisements

2 Comments on “Linux pipe and tee with who”

  1. Chris Tyler says:

    Rather than figure out which tty I’m on, I usually use /dev/tty, which automagically outputs to my current terminal.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s