Case Study: Scripting Suggestions

As part of furthering your knowledge in shell scripts, look at the scripts in /etc/rc.d/init.d. They will show you how a script can give a usage statement if it requires an argument (the case statements), how to test for conditions ([ equals test, but also requires a closing ] to terminate the test—enter man test for details), and proper use of variables. Other scripts you'll find on your Linux system will show you how to loop through a (sometimes previously undetermined) number of items using a for ..do .. done syntax (as in /etc/rc.d/rc. modules). Scripts can be a powerful ally. While you're learning, feel free to borrow from scripts on your system. Also look into sed and awk, which work with lines and paragraphs ...

Get Special Edition Using Linux®, Sixth Edition 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.