#!/usr/bin/bash # # file: dir2tarbz # machine: chronop # purpose: archives directory in .tar.bz2 format # created: pasha jul 8 2000 # modified: pasha sep 15 2007 # modification: preserve date of the original directory; use me_echo and bail_out # . /usr/lib/sh/functions if [ "$1" == "" ]; then echo Usage: $ME \ exit 1 fi # strip (among all) the trailing /, if any d=`basename $1` if [ -f ${d}.tar.bz2 ]; then bail_out ${d}.tar.bz2 already exists fi if [ ! -d $d ]; then bail_out no directory $d fi do_with_echo "tar -cvf $d.tar $d" do_with_echo "touch -r $d $d.tar" do_with_echo "rm -r $d" do_with_echo "bzip2 -v $d.tar" exit 0 # end of dir2tarbz