Use gzip to compress the files in a directory except for already existing .gz files
23
votes
3
answers
40178
views
I have a directory of logs that I would like to set up a job to compress using gzip . The issue is I don't want to recompress the logs I've already compressed.
I tried using
ls | grep -v gz | gzip
, but that doesn't seem to work.
Is there a way to do this? Basically I want to gzip every file in the directory that does not end in .gz.
Asked by jabbajac
(335 rep)
Oct 10, 2014, 03:35 PM
Last activity: Aug 28, 2024, 07:47 PM
Last activity: Aug 28, 2024, 07:47 PM