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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access