CS155

CS155: Introduction to Unix

Fall 2017

Redirection

See this page as a slide show

More Redirection

CS155 Redirection

Streams

Streams and Redirection

Redirecting stderr and stdout

% ls -l
-rw-rw-r-- 1 applin fac 1234 Jan 17 14:26 alpha
-rwxr--r-- 1 applin fac 4918 Jan 15 12:23 beta
% rmdir alpha > output
rmdir: ‘alpha’: Not a directory
%

Why didn’t the error message go to the file output?

Redirect just stdout with > or just stderr with 2> or both stdout and stderr with >&.

Examples

% ls -l gamma delta
-rwxr--r-- 1 applin fac 4918 Jan 15 12:23 gamma
ls: delta: No such file or directory
% ls -l gamma delta >output
ls: delta: No such file or directory
% ls -l gamma delta >&output
%

Modified: 2017-02-03T11:52

User: Guest

Check: HTML CSS
Edit History Source
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2015 Colorado State University
CS Building