Problem Statement:
A bash routine to create a GZIP tarball of a folder's contents with a single command. The tarball name is created using the folder name and the current time stamp. Just add this function to your bashrc file (usually in /etc/bashrc).
Dependencies:
linux, unix, bsd, macos x, bash
Example Usage:
technify$ cd /path/to/some/folder technify$ tarball
function tarball() {
pwd > /tmp/x
awk -F/ '{print $NF}' /tmp/x > /tmp/y
mydir=`cat /tmp/y`
date >/tmp/x
sed 's/ / /g' /tmp/x>/tmp/y
sed 's/:/./g' /tmp/y>/tmp/x
sed 's/ /./g' /tmp/x>/tmp/y
awk -F. '{print $8 "." $2 "." $3 "." $4 $5}' /tmp/y>/tmp/x
mydate=`cat /tmp/x`
TARBALL=$mydir.$mydate
date > /tmp/version.txt
sudo cp /tmp/version.txt .
echo " Beginning the tar..."
sudo tar -cf $TARBALL.tar *
echo " Gzipping the tarball..."
sudo gzip $TARBALL.tar
echo " Successfully created $TARBALL.tar.gz"
}