Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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