Home / Alt manpages / prezip(1)

  • prezip(1)
  • User command
  • linux

Compress Aspell Word Lists Safely with prezip

You will finish with a small, repeatable workflow for compressing a sorted word list with prezip, checking the result with preunzip or precat, and keeping the source file available for recovery. The installed command is prezip 0.1.1 (2004-11-06), supplied here by aspell 0.60.8.1-1build1.

Allow about ten minutes. You need a shell and a text file whose records are already sorted, such as an Aspell word list. No elevated privileges are needed for the examples. Do not use prezip as a general replacement for gzip or another binary compressor: its prefix-delta format is intended for sorted word lists and similar text, and can make binary data larger.

1. Check the installed interface

Start by checking the binary and package version. This is read-only and does not need sudo:

$ command -v prezip
/usr/bin/prezip
$ dpkg-query -W -f='${Package} ${Version}\n' aspell
aspell 0.60.8.1-1build1
$ prezip --version
prezip, a prefix delta compressor. Version 0.1.1, 2004-11-06

The three names select different defaults. prezip compresses, preunzip decompresses, and precat decompresses to standard output. They are the same utility with different invocation names, so the explicit options --compress and --decompress are available when a script should make its intent clear.

Checkpoint: if command -v finds a different installation, or the version differs, keep the output from --help with your test notes. Do not assume that an example from another host has the same packaging behaviour.

2. Prepare a suitable input

Use a plain text list with one word or record per line. The prefix relationship between neighbouring records is where prezip saves space, so a sorted list is the normal input. For a harmless test, create a small list in a temporary directory:

$ test_dir=$(mktemp -d /tmp/prezip-test.XXXXXX)
$ printf '%s\n' apple application apply banana banana > "$test_dir/words.txt"
$ sed -n '1,5p' "$test_dir/words.txt"
apple
application
apply
banana
banana

Do not point this command at a dictionary or production file until you have confirmed its backup and restore path. The --sort option sorts and removes duplicates before compression. That changes the logical contents of the list, not just its representation, so leave it out when duplicate records or original ordering are meaningful.

3. Test compression through standard input

The safest first run writes a new output file and leaves the input untouched. With no file names, prezip reads standard input and writes standard output:

$ prezip < "$test_dir/words.txt" > "$test_dir/words.pz"
$ ls -l "$test_dir/words.txt" "$test_dir/words.pz"
-rw-r--r-- ... words.pz
-rw-r--r-- ... words.txt

The sizes and metadata will vary. A non-empty words.pz is only a file check, not proof that the data can be recovered. Keep the original until the round trip has passed.

Checkpoint: verify that the compressed stream expands to the expected text:

$ precat "$test_dir/words.pz"
apple
application
apply
banana
banana

precat is useful in pipelines because it sends decompressed data to standard output. To create a restored file instead, use preunzip -c and redirect it:

$ preunzip -c "$test_dir/words.pz" > "$test_dir/restored.txt"
$ cmp "$test_dir/words.txt" "$test_dir/restored.txt"
$ printf 'round trip: OK\n'
round trip: OK

4. Compress a word-list file

For an existing file, pass its name to prezip. Aspell-style .wl input is normally written as a .cwl output file. Use --keep while testing so the source remains available:

$ cp "$test_dir/words.txt" "$test_dir/list.wl"
$ prezip --keep "$test_dir/list.wl"
$ find "$test_dir" -maxdepth 1 -type f -printf '%f\n' | sort
list.cwl
list.wl
restored.txt
words.pz
words.txt

The generated name is a format convention handled by the utility: list.wl becomes list.cwl. If you do not want the .wl to .cwl rename, pass --nocwl; the compressed file then uses the .wl.pz suffix. Check the actual directory after every file-mode run rather than guessing which input was retained.

Restore the file-mode result to standard output and compare it:

$ preunzip --stdout "$test_dir/list.cwl" > "$test_dir/list-restored.wl"
$ cmp "$test_dir/list.wl" "$test_dir/list-restored.wl"
$ printf 'file round trip: OK\n'
file round trip: OK

5. Decide whether sorting is safe

--sort is a content operation as well as a compression option. It sorts the records and removes duplicates before producing the compressed stream. Use it only when the consumer expects a set-like word list:

$ prezip --sort < "$test_dir/words.txt" > "$test_dir/sorted.pz"
$ precat "$test_dir/sorted.pz"
apple
application
apply
banana

The duplicate banana is gone. If that is not acceptable, discard this compressed output and repeat without --sort. Because the operation is destructive to the list's logical content, keep an unmodified source or use a new destination until the consuming program has been tested.

6. Handle common mistakes

An unexpectedly larger output is not necessarily a command failure. The manual warns that prezip is specialised for sorted word lists and may increase the size of binary data. For arbitrary text, compare it with a general-purpose compressor rather than assuming that the .pz suffix means a useful saving.

If decompression fails, first check that the input really is a prezip stream and that you did not overwrite it with a redirected command. Restore from the retained .wl or original text file, then create a new output path. Do not add --force just to suppress a warning: it changes overwrite handling and should be used only after you have checked the destination.

For scripts, check the exit status and keep diagnostics visible. --quiet suppresses warnings, which can make an automated failure harder to diagnose. The command accepts combined short options, so -cs means the same as -c -s, but long options are easier to audit in maintenance scripts.

There is no service restart, system-wide configuration change or privilege escalation in this workflow. If a dictionary package or application consumes the compressed file, test that consumer before replacing its live file. Recovery is to restore the original retained file or copy the known-good backup back into place; do not delete the only uncompressed copy.

Done means

  • You confirmed the installed prezip and aspell versions.
  • You used a sorted text or word list, not arbitrary binary data.
  • You preserved the source with --keep or a separate backup.
  • precat or preunzip --stdout reproduced the expected records.
  • cmp returned success for an unsorted-operation round trip.
  • You used --sort only after accepting its duplicate-removal behaviour.