Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Command-Line Programs

4. Command-Line Programs

Much of the power that Unix brings to the user is in the command-line tools, where the user can set up pipelines of independent programs that manipulate data. It’s time to take a peek under the hood of a typical command-line tool and see how it works, as many of the command-line concepts (processing arguments, checking the environment) apply to any Unix program. Here you are going to write a program that filters its input by changing any letters it finds to upper or lower case.

Figure 4.1 shows a typical command-line program along with its three communication streams. The standard-in stream (also called “stdin”) supplies data to the program. The data you are to process comes from standard-in. You are done once the stream dries up. While you process the data, you write new data to the standard-out stream (also called “stdout”). If you need to report any errors or output any information other than the processed data, you can write that information to the standard-error stream (also called “stderr”).


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint