Created
March 14, 2015 14:03
-
-
Save narqo/c64a05eadbbcb534de96 to your computer and use it in GitHub Desktop.
Essential shell scripting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Parsing and processing script arguments | |
while [ $# -gt 0 ]; do | |
case $1 in | |
-p) | |
shift | |
PORT=$1 | |
;; | |
--pbuilder-basetgz=*) | |
BASETGZ="$(echo $1 | cut -d = -f 2)" | |
;; | |
--help|-h) | |
usage | |
exit | |
;; | |
*) | |
usage # All other parameters | |
exit 1 | |
esac | |
shift | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A function to generate script logs with timestamp | |
# Usage: | |
# log "$PROGRAM: start" | |
log() { | |
echo [`date +%Y-%m-%d\ %H:%M:%S`] $* | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment