Extracting recursive compressed file directory structures for trace and log analysis

Often when given a CUCM SDL zip file with traces spanning multiple CUCM servers or trace files per server, the trace files provided are zipped.  If you want to use with a grep tool (grep, GrepWin, rummage, etc.), all files need to be recursively extracted and preferably maintain the folder structure to account for duplicate file names per server.

For completeness, here is how to do this on Linux for tar.gz, .gz and .zip files.  This suggests more esoteric log extraction could require more than one method.  xargs usage is fancy as it provides multi-processing support.

.tar.gz:

find sdl_dir/ -type f -name "*.gz" | xargs -P 5 -I fileName sh -c 'tar -xzf fileName -C $(dirname fileName)'

This retains the tarballs in their respective directories.

.gz:

gunzip -r sdl_dir/

Gunzip doesn’t retain the .gz files – each compressed file is restored.

.zip:

find sdl_dir/ -type f -name "*.zip" | xargs -P 5 -I fileName sh -c 'unzip -o -d $(dirname fileName) fileName'

This also retains zip files in their respective directories.

Note: these don’t handle nested compression, which is not an expected use case for CUCM SDL tracing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.