Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/ksh
- #
- # @(#)$Id$
- #
- # Purpose
- tmp=${TMPDIR:-/tmp}/prog.$$
- trap "rm -f $tmp.?; exit 1" 0 1 2 3 13 15
- ...real work that creates temp files $tmp.1, $tmp.2, ...
- rm -f $tmp.?
- trap 0
- exit 0
- arg0=$(basename $0 .sh)
- error()
- {
- echo "$arg0: $*" 1>&2
- exit 1
- }
- vflag=0
- out=
- file=
- Dflag=
- while getopts hvVf:o:D: flag
- do
- case "$flag" in
- (h) help; exit 0;;
- (V) echo "$arg0: version $Revision$ ($Date$)"; exit 0;;
- (v) vflag=1;;
- (f) file="$OPTARG";;
- (o) out="$OPTARG";;
- (D) Dflag="$Dflag $OPTARG";;
- (*) usage;;
- esac
- done
- shift $(expr $OPTIND - 1)
- shift $(($OPTIND - 1))
- : ${PERL:=perl}
- : ${SED:=sed}
- #!/bin/sh
- ## Usage: myscript [options] ARG1
- ##
- ## Options:
- ## -h, --help Display this message.
- ## -n Dry-run; only show what would be done.
- ##
- usage() {
- [ "$*" ] && echo "$0: $*"
- sed -n '/^##/,/^$/s/^## {0,1}//p' "$0"
- exit 2
- } 2>/dev/null
- main() {
- while [ $# -gt 0 ]; do
- case $1 in
- (-n) DRY_RUN=1;;
- (-h|--help) usage 2>&1;;
- (--) shift; break;;
- (-*) usage "$1: unknown option";;
- (*) break;;
- esac
- done
- : do stuff.
- }
- #!/bin/ksh
- # Script to turn lead into gold
- # Copyright (C) 2009 Joe Q Hacker - All Rights Reserved
- # Permission to copy and modify is granted under the foo license
- # Last revised 1/1/2009
- # I am not crazy, this really is the only way to do this
- if [ $i = 1 ]; then
- ... some code
- fi
- [ $i = 1 ] && {
- ... some code
- }
- if [ $i -ne 1 ]; then
- ... some code
- fi
- [ $i = 1 ] || {
- ... some code
- }
- cat << EOF > foo.sh
- printf "%s was here" "$name"
- EOF
- printf "%s was here" "$name"
- #!/bin/bash
- # [ID LINE]
- ##
- ## FILE: [Filename]
- ##
- ## DESCRIPTION: [Description]
- ##
- ## AUTHOR: [Author]
- ##
- ## DATE: [XX_XX_XXXX.XX_XX_XX]
- ##
- ## VERSION: [Version]
- ##
- ## USAGE: [Usage]
- ##
- #!/bin/bash -
- #title :mkscript.sh
- #description :This script will make a header for a bash script.
- #author :your_name_here
- #date :20110831
- #version :0.3
- #usage :bash mkscript.sh
- #notes :Vim and Emacs are needed to use this script.
- #bash_version :4.1.5(1)-release
- #===============================================================================
- set -o errexit
- set -o nounset
- set -o noclobber
- set -o pipefail
- shopt -s nullglob
- set -o errexit -o nounset -o noclobber -o pipefail
- shopt -s nullglob
Add Comment
Please, Sign In to add comment