Linux Today: Linux News On Internet Time.

More on LinuxToday

Linux.com: Shell Skills, Part 2: I/O, Redirection, and Pipes

Jul 04, 2000, 14:05 (1 Talkback[s])
(Other stories by Tom Dominico)


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

"In this installment of the "Shell Skills" series, you'll receive the background you need before you can start stringing commands together like a pro. Specifically, we're going to talk about terms such as "standard input", "standard output", "redirection", and "piping". Don't be intimidated - we'll give you some examples, and soon you'll be one step closer to mastering the shell."

"Often, a command needs someplace to send information, often in the form of text. This place is called "standard output". So, "where" exactly is that? Is it a text file, or the terminal screen, or a printer? Well, it can be any of those places. The key is something called "redirection."

"By default, the shell "redirects" any output from a command to a special file that represents your terminal. (In Linux, all devices are represented by special files under the "/dev" directory.) Your terminal is represented by "/dev/ttyn", where n is a unique identifier for that particular terminal. So, by default, all information from a command will be sent to the terminal window. For example, in the case of the "ls" command, this would be a directory listing. There is also a second type of output, known as "standard error". It can be used by programs to separate regular output from error messages, so that they don't get mixed up. For example, you might want to save a log of only the error messages generated by a program. Later in this article, we'll show you how you can redirect standard output and/or standard error to someplace other than the terminal."

Complete Story

Related Stories: