You can use the following command to gzip and keep the original file on a Unix or Linux command line:
gzip -c file.txt > file.txt.gz
This will create a gzipped file file.txt.gz
and keep the original file.txt
intact. The -c
option tells gzip
to write the output to standard output, which is redirected to a new file file.txt.gz
.