Skip to content

Instantly share code, notes, and snippets.

@narqo
Created March 14, 2015 14:03
Show Gist options
  • Save narqo/c64a05eadbbcb534de96 to your computer and use it in GitHub Desktop.
Save narqo/c64a05eadbbcb534de96 to your computer and use it in GitHub Desktop.
Essential shell scripting
# 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
# 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