I tried this command to compress all the css files in all subdirectories.
find . -iname "*.css*" -exec gzip -c '{}' > '{}'.gz \;
But it only creates a {}.gz file. I ended up using this:
find . -iname "*.css" -exec sh -c "gzip -c '{}' > '{}'.gz" \;
which works well.
The question is why the first one didn't work and second one did?
Note: I could easily use gzip -k switch to keep the source files, but gzip on CentOS 7 does not support it.
{}
insidesh -c
. Please read this. – pLumo Jul 08 '19 at 11:43