Skip to Content
Ubuntu: Up and Running
book

Ubuntu: Up and Running

by Robin Nixon
April 2010
Beginner
464 pages
12h 7m
English
O'Reilly Media, Inc.
Content preview from Ubuntu: Up and Running

Standard Input, Output, and Error

In the previous section, we were redirecting streams known as standard input and standard output. When using a < redirection operator, you are telling the operating system that for just this one command it should ignore the standard input device (which is your keyboard) and instead take its input from a file.

Likewise, when using the > operator you are telling Ubuntu to ignore the standard output device (which is your monitor or, more precisely, the Terminal window) and instead send its output to the supplied file.

You may recall from the section The find Command that sometimes an error message would be displayed when access to a particular folder was not allowed, such as with the following command, in which some of the folders are not permitted to be searched by regular users:

find / -name blackjack

Try this command again now, and you’ll see a whole bunch of error messages scroll past, obscuring the few matches we are interested in.

There’s actually a simple solution for this, which is to strip out the error messages from the useable output. In the previous example we separated the error messages from the output we wanted by piping the output through the more command. But how did it do that?

Streams and Handles

The answer is that Ubuntu uses three different streams for input, output, and error messages, and when you use a > or | for redirection or piping, it affects only standard output, not standard error. This means that when you type this:

find / -name ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ubuntu Made Easy

Ubuntu Made Easy

Rickford Grant, Phil Bull
Ubuntu for Non-Geeks, 4th Edition

Ubuntu for Non-Geeks, 4th Edition

Rickford Grant, Phil Bull

Publisher Resources

ISBN: 9781449382827Errata Page