Last Updated: May 06, 2023
·
106
· Lars Van Casteren

Who says pigz can't fly?

find . -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -I{} sh -c 'dir=$(basename "{}"); tar -cf - "$dir" | pigz -p 10 > "${dir}.tar.gz"

This nifty command quickly generates compressed tar archives (.tar.gz) of all subdirectories in the current directory (excluding the current directory itself) using tar and pigz. By using pigz instead of tar -c, you can specify the number of parallel threads to use for compression, resulting in much faster .gz archive creation. Watch those directories soar like a herd of flying pigs with pigz!