Created
September 16, 2013 14:52
-
-
Save decasm/6581718 to your computer and use it in GitHub Desktop.
BASH script template
This file contains 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
#!/bin/bash | |
# Begin script | |
############## | |
#$# creator : | |
#%# email: | |
#$# created : Mon Sep 16 10:44:12 2013 | |
#$# title : | |
#$# description : | |
#$# usage : | |
########## Define a usage function | |
function usage { | |
echo "Usage: $this args" | |
if [ "$1" = "exit" ]; then exit; fi | |
} | |
########## Set to "false" to turn verbose off | |
function echo_stdout { echo "$@"; } | |
function echo_stderr { echo "$@" >& 2; } | |
# Set verbose to 'echo_stderr' or 'echo_stdout' to see output trace info | |
verbose=false | |
$verbose Verbose output on ${verbose##*_} | |
########## Setup some common paths | |
# The absolute, canonical ( no ".." ) path to this script | |
canonical=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)/$(basename -- "$0")") | |
# Just the filename of this script | |
this=$(basename $canonical) | |
$verbose This: $this | |
# The directory this script is in | |
here=$(dirname $canonical) | |
$verbose Here: $here | |
########## When the script is being executed | |
today=$(date +%F) | |
now=$(date +%H:%M:%S) | |
########## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment