October 19, 2014
 
 
RSSRSS feed

The Unix Shell - Part II

Introduction,Standard Input and Output.

  • September 2, 1999
  • By Steve Singer
Introduction

At first glance many people think the Unix Shell is a more cryptic version of the MS-Windows/DOS command prompt. However, the Unix shell can do much more than launch programs and copy files. Sequences of commands can be strung together in "Shell Scripts" to automate tedious or repetitive tasks. Unix systems provide a series of tools that are helpful when writing shell scripts. Typically each tool performs a specific task, accepting input from the "standard input" source and sending its output to the "standard output source".

Standard Input and Output

Non-Graphical Unix programs typically read input from what is called the "standard input stream." When a program is started up from the command line, standard input (STDIN) defaults to the keyboard. Characters typed on the keyboard are sent to the program for processing. Similarly, the standard output (STDOUT) of a program started from the command line is the screen. Normal output destined for the user's screen is sent to STDOUT, but error messages are often sent to the standard error device (STDERR); by default STDERR goes to the screen as well. Sometimes you don't want program output to go to the screen; it might be more convenient to save to a file, or have your program read from a file. Redirection allows you to easily accomplish this.

Sitemap | Contact Us