Home / Alt manpages / prezip(1)

  • prezip(1)
  • User command
  • linux

Compress Aspell Word Lists Safely with prezip

prezip is a specialist tool, not a general compressor, and using it on the wrong kind of data will actually make files bigger. It is a prefix-delta compressor built for sorted word lists and similar text, which is exactly what Aspell dictionaries are made of. This walks through compressing a list, checking the round trip with preunzip or precat, and keeping the source safe while you test. The installed command is prezip 0.1.1 (2004-11-06), supplied 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 any of this.

1. Check the installed interface

Start with the binary and package version. This is read-only and needs no 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
  • prezip compresses.
  • preunzip decompresses.
  • precat decompresses to standard output.

All three names are the same utility with different invocation names, so the explicit --compress and --decompress options exist for when a script needs to say what it means.

Checkpoint

If command -v finds a different install, or the version differs, keep the output of --help with your test notes. An example from another host will not necessarily match your packaging.

2. Prepare a suitable input

Use a plain text list, one word or record per line. Prezip saves space from the prefix relationship between neighbouring records, so a sorted list is the normal input. Build a harmless test 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 at a dictionary or production file until you have confirmed its backup and restore path. --sort sorts and removes duplicates before compressing, which changes the logical contents of the list, not just its representation, so leave it out whenever duplicate records or original order actually matter.

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

Sizes and metadata will vary. A non-empty words.pz only proves the file was written, not that the data can be recovered. Keep the original until the round trip has actually passed.

Checkpoint

Verify the compressed stream expands back to the expected text:

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

precat is handy in pipelines because it writes decompressed data straight 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 directly. Aspell-style .wl input is normally written out as a .cwl file. Use --keep while testing so the source stays around:

$ 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 the utility handles for you: list.wl becomes list.cwl. If you do not want that rename, pass --nocwl and the compressed file uses the .wl.pz suffix instead. Check the actual directory after every file-mode run rather than guessing which input survived.

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

Warning

--sort is a content operation, not just a compression tweak. It sorts the records and removes duplicates before producing the compressed stream, so only use it when the consumer genuinely 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 for good in that output. If that is not acceptable, discard the compressed file and run again without --sort. Because the operation changes the list's logical content, keep an unmodified source, or write to a new destination, until the consuming program has actually been tested against it.

Common traps

  • Output got bigger, not smaller. Not necessarily a failure: the manual warns prezip is specialised for sorted word lists and may increase the size of binary data. Compare against a general-purpose compressor before assuming the .pz suffix means a saving.
  • Decompression fails. First check the input really is a prezip stream and that you have not overwritten it with a redirected command. Restore from the retained .wl or original text, then write to a new output path. Do not add --force just to silence a warning: it changes overwrite handling and should only be used once you have checked the destination.
  • Scripted runs need visible diagnostics. --quiet suppresses warnings, which can hide an automated failure. Combined short options work as expected, so -cs means the same as -c -s, but long options are easier to audit later.

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

Done means

  • Versions confirmed. Installed prezip and aspell versions were checked.
  • Right kind of input. A sorted text or word list was used, not arbitrary binary data.
  • Source preserved. --keep or a separate backup kept the original around.
  • Round trip verified. precat or preunzip --stdout reproduced the expected records.
  • cmp passed for an unsorted-operation round trip.
  • --sort used deliberately, only after accepting its duplicate-removal behaviour.