LinuxCommandLibrary

znew

Recompress .gz files to newer format

TLDR

Recompress a file from .Z to gzip format

$ znew [path/to/file1.Z]
copy

Recompress multiple files and display the achieved size reduction % per file
$ znew -v [path/to/file1.Z path/to/file2.Z ...]
copy

Recompress a file using the slowest compression method (for optimal compression)
$ znew -9 [path/to/file1.Z]
copy

Recompress a file, [K]eeping the .Z file if it is smaller than the gzip file
$ znew -K [path/to/file1.Z]
copy

SYNOPSIS

znew [options] file...

PARAMETERS

-v
    Verbose mode. Prints more information about what znew is doing.

-f
    Force. Forces recompression even if the new file is larger or already exists.

-q
    Quiet mode. Suppresses most output messages.

-t
    Test mode. Tests the file but does not recompress.

-n
    Don't actually do anything, just show what would happen.

-c
    Copy the compressed file and do not delete the original compressed file.

-d
    Delete the original compressed file even if errors occur during recompression.

-V
    Display version information.

-L
    Display license information.

-9
    Use the best (slowest) compression method.

-0
    Use the fastest (worst) compression method.

-r
    Recurse directories.

DESCRIPTION

znew is a command-line utility used to recompress compressed files (typically ending in `.Z`) to the more efficient `.gz` (gzip) format. This can save disk space and potentially improve decompression speed. It attempts to determine the best compression level for the new `.gz` file by analyzing the existing `.Z` file. It provides options for controlling the compression level, handling existing files, and operating recursively on directories. Essentially, znew automates the conversion of older compressed files to a more modern standard. It's particularly useful in environments where legacy compressed files are still present but need to be modernized for better compatibility or storage efficiency. The main benefit is optimizing existing compressed archives without manual intervention.

It determines if recompression is necessary based on file size comparisons. It only rewrites the compressed files if the new ones are smaller.
Note: This command might not be available in some modern distributions.

CAVEATS

znew primarily targets `.Z` files compressed with the older `compress` utility. Its effectiveness on other compressed file types might be limited. It relies on the `gzip` utility being available on the system. Error handling might not be robust in all cases.

EXIT STATUS

The znew command returns an exit status of 0 for successful operation, and a non-zero value for errors.
Important: Check return value to ensure file conversions were successful before deleting your .Z files.

EXAMPLES

Recompress a file: znew myfile.Z

Recompress verbosely with best compression: znew -v -9 myfile.Z

Recompress all .Z files in a directory recursively: znew -r directory

HISTORY

znew was created to help transition from the older `compress` format to the more widely supported `gzip` format. It gained popularity as disk space became more valuable and `gzip`'s superior compression became advantageous. The command was prevalent in older Unix and Linux systems but might be less common in modern distributions where `gzip` is the standard compression tool.

SEE ALSO

gzip(1), compress(1), gunzip(1)

Copied to clipboard