#!/bin/sh print_usage() { echo "$(basename $0) -- Create bzip2 compressed TAR archive." echo "Usage: $(basename $0) DIR" } if [ $# -ne 1 ]; then print_usage exit 1 fi DIR=${1%/} BASE=$(basename ${DIR}) # Checking if directory exists. if [ ! -d ${DIR} ]; then echo "$0: Directory ${DIR} not found." exit 1 fi # Decompressing file to standard output and piping result to bzip2 tar cvf - ${DIR} | bzip2 -9 > ${BASE}.tar.bz2 exit $?