12.07.2015 Views

Advanced Bash-Scripting Guide

Advanced Bash-Scripting Guide

Advanced Bash-Scripting Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

# -a = all, -h = help, etc.if [ $# -ne $Number_of_expected_args ]thenecho "Usage: `basename $0` $script_parameters"# `basename $0` is the script's filename.exit $E_WRONG_ARGSfiMany times, you will write a script that carries out one particular task. The first script in this chapter isan example of this. Later, it might occur to you to generalize the script to do other, similar tasks.Replacing the literal ("hard-wired") constants by variables is a step in that direction, as is replacingrepetitive code blocks by functions.2.1. Invoking the script<strong>Advanced</strong> <strong>Bash</strong>-<strong>Scripting</strong> <strong>Guide</strong>Having written the script, you can invoke it by sh scriptname, [12] or alternatively bashscriptname. (Not recommended is using sh

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!