Skip to content

Instantly share code, notes, and snippets.

@wtnabe
Created August 7, 2010 02:31
Show Gist options
  • Save wtnabe/512350 to your computer and use it in GitHub Desktop.
Save wtnabe/512350 to your computer and use it in GitHub Desktop.
appending gziped file to tar archive
#! /bin/sh
ARCHIVE=logs.gz.tar
#
# create files
#
echo "create dummy files ..."
for i in `awk '
BEGIN {
for ( i = 1; i <= 20; i++ ) {
printf( "%02d.log\n", i );
}
}
'`; do
dd if=/dev/zero of=$i bs=10m count=1 > /dev/null 2>&1
done
#
# archive files partway
#
echo "archive dumme files partway ..."
find . -name '[01]*.log' | sort | xargs gzip
find . -name '*.gz' | cpio -o -H ustar > $ARCHIVE
rm *.gz
#
# display archived file list
#
echo "see archived files below:"
tar tf $ARCHIVE
#
# append last file to archive
#
echo "appending ..."
find . -name '*.log' | xargs gzip
find . -name '*.gz' | cpio -o -A -H ustar -O $ARCHIVE
rm *.gz
echo "see archived files below:"
tar tf $ARCHIVE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment