Created
August 7, 2010 02:31
-
-
Save wtnabe/512350 to your computer and use it in GitHub Desktop.
appending gziped file to tar archive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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