Introduction

Introduction

The concept of a standard input and a standard output is one of the most useful features of UNIX-like operating systems. The idea is that every program, no matter how diverse, should be reading input and generating output in a uniform, clearly understood way. Once you have that, it makes it much easier for programs to talk to one another directly. It is also possible to write generic programs that bridge the input and output of any two programs, which is an amazingly handy ability to have.

To put it another way, for the most part, standard input and standard output are nothing more than the keyboard and the monitor, respectively. But if you want to, you can redirect the output that would have gone to your monitor to somewhere more useful, such as a file or the input of another program. Similarly, you can set up files that contain sheaves of data and use that as input to some command, or read the input for command A directly from the output of command B.

In addition, a third mechanism known as standard error has been provided to programs for displaying error messages.

>

Send standard output to a file.

<

Read standard input from a file.

2>

Redirect standard error as specified.

>>

Append standard output to the specified file.

|

Couple the standard output of one program to the standard input of another program.

tee

Copy standard input to a file and also to standard output.

script

Save the activity on your screen in a file.

xargs

Read multiple arguments from standard input and use them as arguments to some specified command.

 



Linux Desk Reference
Linux Desk Reference (2nd Edition)
ISBN: 0130619892
EAN: 2147483647
Year: 2000
Pages: 174
Authors: Scott Hawkins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net