#!/bin/bash # # file: dir2tarxz # machine: chronop # purpose: archives directory in .tar.xz format # created: pasha sep 22 2010 (after dir2tarbz) # . /usr/local/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.xz ]; then bail_out ${d}.tar.xz 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 -rf $d" do_with_echo "xz -v ${d}.tar" exit 0 # end of dir2tarxz