How to gzip each file separately inside a folder and then if successful delete the original file
bash, gzip
Solution
I don't understand the issue you're having. According to the gzip man page:
Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times.
My only guess is you're having permissions issues. Make sure you're logged in as the owner of the file that you are gzipping. However, in the gzip version on my machine, I get an obvious `Operation not permitted` warning when I try to gzip a file that I don't own. The operation still succeeds, but it's clear what is going on.
Problem
I use the following command for zipping each file in a folder separately: ``` for file in *; do gzip "$file"; done ``` But it keeps the original files. I want to know if there is a way to delete the files automatically after they're successfully gzipped. Thanks.