Self-Help Scripts

As my mind gets more cluttered with UNIX commands and other technical flotsam, my ability to remember the expected syntax of a particular command or script becomes limited.

One of the techniques I use to quickly recall which options are legitimate and what the order of the parameters is supposed to be is to type the command with no other syntax. Usually this is incorrect for the command or script in question. If the script has been designed with self-help in mind, it displays a little syntax reminder onscreen. This functions as a mini man page, as you can see in the following example.

You can alternatively set up your script to react to a parameter of ? or -help.

$ gcdksh
Usage: gcdksh {integer_1}  {integer_2}  ...
$
				

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.