27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

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.

Example 17−11. A self−documenting script<br />

<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />

#!/bin/bash<br />

# self−document.sh: self−documenting script<br />

# Modification of "colm.sh".<br />

DOC_REQUEST=70<br />

if [ "$1" = "−h" −o "$1" = "−−help" ] # Request help.<br />

then<br />

echo; echo "Usage: $0 [directory−name]"; echo<br />

sed −−silent −e '/DOCUMENTATIONXX$/,/^DOCUMENTATION/p' "$0" |<br />

sed −e '/DOCUMENTATIONXX/d'; exit $DOC_REQUEST; fi<br />

:

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

Saved successfully!

Ooh no, something went wrong!