gzip command line usage

To gzip a file while keeping a copy of the original file use the following command:

gzip -c -- file1.ext > file2.ext.gz

Also, you can define a shell function with the following code:

function gzipkeep {
if [ -f "$1" ] ; then
gzip -c -- "$1" > "$1.gz"
fi
}
and then

gzipkeep file.txt
 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.