#!/bin/sh # # $Id: tardir,v 1.3 1997/07/22 23:46:41 vogelke Exp $ # # NAME: # tardir # # SYNOPSIS: # tardir [dir ...] # # DESCRIPTION: # "tardir" compresses everything beneath one or more directories. # A file called "archive.tar.gz" is left in each directory. # # AUTHOR: # Karl Vogel # Sumaria Systems, Inc. PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/gnu export PATH case "$#" in 0) list="." ;; *) list="$*" ;; esac # # Compress each directory on the command line by creating a tar # file of the contents and gzipping it. # dir=${TMPDIR:-/tmp} tmp="$dir/tardir.$$" trash="$dir/trash.$$" output="archive.tgz" output2="archive.tar.gz" for dir in $list do if test -d $dir; then ( cd $dir if test -f "$output" -o -f "$output2" then echo "$dir already compressed." >& 2 else pwd tar cf $tmp . find . -print | tail +2 > $trash test -s "$trash" && xargs rm -rf < $trash gzip < $tmp > $output fi ) else echo "$dir: not a directory" >& 2 fi done rm -f $trash $tmp exit 0