Accepting Command-Line Arguments in Your Scripts

Suppose that at the end of every month you need to send a progress report to your boss. You might set up a script to address an email message to your boss, provide an appropriate subject line, and send the file containing the progress report. You’d likely have this script automatically address a message to your boss and put in the subject line, but you’d want to use command-line input to tell the script which file you want to send. By using command-line input, you can give your scripts a bit more flexibility and still have much of a process automated for you. You run the script and specify the input at the shell prompt, as shown in Figure 10.7.

Figure 10.7. Using command-line input, you can add ...

Get Unix Third Edition: Visual Quickstart Guide 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.