In the third edition of "Learning the Bash shell" by Newham and Rosenblatt the page 19 mentions uncompressing a file named gcc.tar.Z.

Type uncompress gcc.tar & (you can omit the Z).

Why do the authors say "you can omit the Z"? Why not just keeping it?...

By man uncompress in Ubuntu 16.04 I reached to the Gunzip ("Gzip") manual that says:

If the compressed file name is too long for its file system, gzip truncates it. Gzip attempts to truncate only the parts of the file name longer than 3 characters.

gunzip takes a list of files on its command line and replaces each file whose name ends with .gz, -gz, .z, -z, or _z (ignoring case) and which begins with the correct magic number with an uncompressed file without the origi‐ nal extension. gunzip also recognizes the special extensions .tgz and .taz as shorthands for .tar.gz and .tar.Z respectively. When compressing, gzip uses the .tgz extension if necessary instead of truncating a file with a .tar extension.

gunzip is sometimes able to detect a bad .Z

I admit it is not fully clear to me why the program has the aforementioned behavior.


1 Answer 1


I wouldn’t say “should”, but you certainly can, because the uncompress utility’s file argument is specified thus, as a convenience:

A pathname of a file. If file already has the .Z suffix specified, it shall be used as the input file and the output file shall be named file with the .Z suffix removed. Otherwise, file shall be used as the name of the output file and file with the .Z suffix appended shall be used as the input file.

(I haven’t checked, but it’s likely this was the pre-existing behaviour, carried over to the spec.)

This is also supported by gzip, at least with its default .gz extension:

echo Hello > test
gzip test
ls -l test*
gunzip test
ls -l test*
cat test
  • Did you mean that the first test will have .z? Apr 26, 2018 at 5:56
  • No, I meant that gunzip doesn’t require you to specify the extension. Apr 26, 2018 at 6:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .