in reply to Re: Zipping the contents of a directory by filename
in thread Zipping the contents of a directory by filename

This depends greatly on the content of the pdf. I just gzipped a few random pdfs and got between 4.2% and 51.6% reduction.

> ls -lh ?.pdf -rwxrwx--- 1 root vboxsf 4.0M Jun 2 15:01 1.pdf* -rwxrwx--- 1 root vboxsf 1.9M Jun 2 15:01 2.pdf* -rwxrwx--- 1 root vboxsf 1.2M Jun 2 15:01 3.pdf* -rwxrwx--- 1 root vboxsf 340K Jun 2 15:01 4.pdf* -rwxrwx--- 1 root vboxsf 69K Jun 2 15:01 5.pdf* -rwxrwx--- 1 root vboxsf 416K Jun 2 15:01 6.pdf* > gzip -v ?.pdf 1.pdf: 19.5% -- replaced with 1.pdf.gz 2.pdf: 23.2% -- replaced with 2.pdf.gz 3.pdf: 51.6% -- replaced with 3.pdf.gz 4.pdf: 4.2% -- replaced with 4.pdf.gz 5.pdf: 8.3% -- replaced with 5.pdf.gz 6.pdf: 6.2% -- replaced with 6.pdf.gz > ls -lh ?.pdf.gz -rwxrwx--- 1 root vboxsf 3.3M Jun 2 15:01 1.pdf.gz* -rwxrwx--- 1 root vboxsf 1.4M Jun 2 15:01 2.pdf.gz* -rwxrwx--- 1 root vboxsf 557K Jun 2 15:01 3.pdf.gz* -rwxrwx--- 1 root vboxsf 326K Jun 2 15:01 4.pdf.gz* -rwxrwx--- 1 root vboxsf 63K Jun 2 15:01 5.pdf.gz* -rwxrwx--- 1 root vboxsf 390K Jun 2 15:01 6.pdf.gz*

Replies are listed 'Best First'.
Re^3: Zipping the contents of a directory by filename
by karlgoethebier (Abbot) on Jun 02, 2025 at 15:29 UTC

    Interesting. Here is a benchmark, to complete the picture:

    hyperfine --runs 10000 'gzip -k -c a.pdf -c b.pdf c.pdf > out.gz' 'tar + cf out.tar a.pdf b.pdf c.pdf' # truncated output Summary 'tar cf out.tar a.pdf b.pdf c.pdf' ran 1.72 ± 0.57 times faster than 'gzip -k -c a.pdf -c b.pdf c.pdf > o +ut.gz'

    Possibly too few files but tar is significantly faster.