Recursive Compression with find Using gzip Command in Linux
To compress all files in a directory and its subdirectories, the find
command can be combined with gzip:
find /path/to/directory -type f -exec gzip {} \;
This command recursively compresses all files in the specified directory.
Gzip Command in Linux
gzip command compresses files. Each single file is compressed into a single file. The compressed file consists of a GNU zip header and deflated data. If given a file as an argument, gzip compresses the file, adds a “.gz” suffix, and deletes the original file. With no arguments, gzip compresses the standard input and writes the compressed file to the standard output.