You are previewing The Linux Command Line.

The Linux Command Line

Cover of The Linux Command Line by William E. Shotts Jr. Published by No Starch Press
O'Reilly logo

A More Complete Application

After a long hiatus, we are going to resume work on our sys_info_page program. Our next addition will add several command-line options to the program as follows:

  • Output file. We will add an option to specify a name for a file to contain the program’s output. It will be specified as either -f file or --file file.

  • Interactive mode. This option will prompt the user for an output filename and will determine if the specified file already exists. If it does, the user will be prompted before the existing file is overwritten. This option will be specified by either -i or --interactive.

  • Help. Either -h or --help may be specified to cause the program to output an informative usage message.

Here is the code needed to implement the ...

The best content for your career. Discover unlimited learning on demand for around $1/day.