Skip to content

Instantly share code, notes, and snippets.

@wraithmonster
wraithmonster / marmdir.sh
Created March 4, 2012 22:04
Archive the specified directory, then remove it
#!/bin/bash
################################################################################
#
# Title: marmdir.sh
# Description: Archive the specified directory, then remove it
# Author: wraithmonster
# Reference: http://www.apl.jhu.edu/Misc/Unix-info/tar/tar_28.html
# http://bit.ly/bash-string-length
# http://www.linux.com/archive/feature/120291
@wraithmonster
wraithmonster / strip-whitespace.sh
Created March 4, 2012 21:31
Strip whitespace & trailing slashes in bash
# References:
# http://bit.ly/bash-exit-status
# http://bit.ly/bash-remove-slash
# http://www.delorie.com/gnu/docs/wget/wget_27.html
# Strip whitespace
WS=`expr "$1" : '[[:space:]]*\(.*\)[[:space:]]*$'`
# Strip whitespace and remove any trailing slashes
WS_AND_SLASHES=`expr "$1" : '[[:space:]]*\(.*\)[[:space:]]*$' | sed -e 's/\\/$//g'`
@wraithmonster
wraithmonster / install-node.sh
Created February 17, 2012 17:53
Installs node.js on Ubuntu
#!/bin/bash
# Title: install-node.sh
# Description: Installs node.js.
# Author: wraithmonster
# Reference: https://github.com/joyent/node/wiki/Installation
# Web framework - http://expressjs.com/
# Node Pkg Manager - https://github.com/isaacs/npm
#
################################################################################
@wraithmonster
wraithmonster / install-couchdb.sh
Created February 17, 2012 17:46
Installs the latest CouchDB version on Ubuntu from source, not from a repository
#!/bin/bash
# Title: install-couchdb.sh
# Description: Installs the latest CouchDB version from source,
# not from a repository.
# Author: wraithmonster
# Reference: https://github.com/iriscouch/build-couchdb
# http://comments.gmane.org/gmane.comp.db.couchdb.user/16292
# Uninstalling from Ubuntu's repository:
# http://serverfault.com/questions/348044
# http://stackoverflow.com/questions/8783621
@wraithmonster
wraithmonster / process-command-line-options.sh
Created February 17, 2012 14:53
Parse command line options (parameters) in bash.
################################################################################
# Command line processing
################################################################################
# Parse the command line arguments.
while [ "$#" -gt "0" ]; do
case "$1" in
# TODO: Create some script options.
# EXAMPLE: Uncomment below to assign a 'destination directory', DST_DIR,