WSU logo


College of Engineering & CS
Wright State University
Dayton, Ohio 45435-0001

CEG 333: Introduction to Unix

Prabhaker Mateti

Standard Files, Redirection and Pipes


"stdout" and "stdin" are the normal text input and output of commands, i.e. what shows up in the terminal. C++ programmers can think of them as like "cout" and "cin". There is also a "stderr" for the output of error messages.

The shell usually refers to them by number: stdin == 0, stdout == 1, and stderr == 2.

Command Summary Examples
> FILE Redirect stdout. c1 > FILE Overwrite the contents of a file with the stdout of "c1".
c1 >> FILE Append the stdout of "c1" to a file.
< FILE Redirect stdin. c1 < FILE Use the contents of a file as the stdin for "c1".
c1 | c2 Pipe the stdout of "c1" to the stdin of "c2". ps aux | grep Emacs Shows the PIDs of all running Emacs processes.