DEVFYI - Developer Resource - FYI

What does the command “ $who | sort –logfile > newfile” do?

Unix Interview Questions


(Continued from previous question...)

79. What does the command “ $who | sort –logfile > newfile” do?

The input from a pipe can be combined with the input from a file . The trick is to use the special symbol “-“ (a hyphen) for those commands that recognize the hyphen as std input.
In the above command the output from who becomes the std input to sort , meanwhile sort opens the file logfile, the contents of this file is sorted together with the output of who (rep by the hyphen) and the sorted output is redirected to the file newfile.

(Continued on next question...)

Other Interview Questions