You just leverage the find
command:
find . -name "*.csv"
With the gzip
command:
gzip -v -k -9 filename
-v = verbose
-k = keeps file (default is to zip and delete old)
-9 = compression, default 6, 9 max compression
filename
And then you mix the two:
find . -name "*.csv" -exec gzip -v9 {} \;
You should also be aware of pigz
, a drop-in replacement for gzip
, present in most distros, that (p)arallel gzips your files. For multicore systems, this will yield massively superior results:
find . -name "*.csv" -exec pigz -v9 {} \;
As an Amazon Associate I may earn from qualifying purchases on some links.
If you found this page helpful, please share.