[Linux/macOS] Batch Compress Files to .gz with gzip Command
I’ll introduce how to batch compress files to .gz format using the gzip command on Linux and macOS.
A sudden surge of logs caused *.log files to bloat and resulted in disk full.
I needed to free up disk space immediately, so I used the gzip command to batch compress *.log files.
Run the gzip * command in the directory containing log files to complete the batch compression task.
gzip *
Even if .gz files already exist, you’ll just see an “unchanged” message like:
gzip: example.log-2019-10-29.gz already has .gz suffix -- unchanged
So it’s fine. Don’t worry about anything and just run gzip * in the directory containing log files.
That’s all from the Gemba.