09-24-2004
From the man page for compress on HPUX:
Quote:
-b maxbits Specify the maximum number of bits the
compress algorithm will use. The default is
16 and the range can be any integer between 9
and 16.
compress uses the modified Lempel-Ziv algorithm popularized in A
Technique for High Performance Data Compression , Terry A. Welch, IEEE
Computer, vol. 17, no. 6 (June 1984), pages 8-19. Common substrings
in the file are first replaced by 9-bit codes 257 and up. When code
512 is reached, the algorithm switches to 10-bit codes and continues
to use more bits until the limit specified by the -b flag is reached
(default 16).
After the maxbits limit is attained, compress periodically checks the
compression ratio. If it is increasing, compress continues to use the
existing code dictionary. However, if the compression ratio is
decreasing, compress discards the table of substrings and rebuilds it
from scratch. This allows the algorithm to adapt to the next "block"
of the file.
Note that the -b flag is omitted for uncompress since the maxbits
parameter specified during compression is encoded within the output,
along with a magic number to ensure that neither decompression of
random data nor recompression of compressed data is attempted.
Using the default, usually 16, is probably the best choice.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Anybody know what happened here?
162 lab2-36:~/try_direct/another> compress url.txt
url.txt: -- file unchanged (8 Replies)
Discussion started by: endeavour1985
8 Replies
2. Shell Programming and Scripting
Hi Friends,
I have a directory under which 10 more directories are there.
In each 10 directories there are several files.
I want to do FTP. But in FTP we cannt Transfer the main directory.
each Time we have to go to the respective directry and then we have to to FTP.
For this instance I... (9 Replies)
Discussion started by: deep_kol
9 Replies
3. UNIX for Dummies Questions & Answers
People i have files.arc i need to compress one by one...but they need to have the same date for example
jan 30 1234.arc
jan 30 12334.arc
jan 30 rejrne.arc
jan 30 e423e4.arc
jan 30 afdhnfhd.arc
jan 31 aresdfds.arc
I need to compres the jan 30 .arc only
thank you very much (1 Reply)
Discussion started by: enkei17
1 Replies
4. UNIX for Dummies Questions & Answers
Is there a way to copy a file and compress it at the same time?
I realize the file can be copied and then compressed, but I was wondering if it's possible to do it in a one-line command and for that matter, if it would be more efficient to perform the operation with a one-line command?
Thanks. (5 Replies)
Discussion started by: here2learn
5 Replies
5. UNIX for Dummies Questions & Answers
Hi All !
We have to compress a big data file in unix server and transfer it to windows and uncompress it using winzip in windows.
I have used the utility ZIP like the below.
zip -e <newfilename> df2_test_extract.dat
but when I compress files greater than 4 gb using zip utility, it... (4 Replies)
Discussion started by: sakthifire
4 Replies
6. Programming
Hi all,
I would like to know if an API for compress (.Z) exists in C ?
I want to write a program which process a large number of data files with efficient compression at the end.
Thanks
http://fedora.unix.com/images/misc/progress.gif (4 Replies)
Discussion started by: domiq44
4 Replies
7. Shell Programming and Scripting
hi guys,
i've read that i need to use tar first before gzip. just wanted to be sure if there's no way of compressing a folder with all its files like winzip in windows?
using tar then gzip in unix, i will need to open 2 zip files in order to get the files unlike winzip.
i'd appreciate any... (2 Replies)
Discussion started by: adshocker
2 Replies
8. Web Development
Hi all,
Someone please help with a script that will compress a directory for backed up:
home/main/directory2Bcompressed/
home/main/directory2Bcompressed_date.zip
Then all the files in the directory are to be deleted right afterwards, emptied out for new files to come in:
... (6 Replies)
Discussion started by: MrDude
6 Replies
9. UNIX for Dummies Questions & Answers
I have scheduled couple of shell scripts to run using 'at' command.
The o/p of at -l is:
$ at -l
1320904800.a Thu Nov 10 01:00:00 2011
1320894000.a Wed Nov 9 22:00:00 2011
1320876000.a Wed Nov 9 17:00:00 2011
$ uname -a
SunOS dc2prcrptetl2 5.9 Generic_122300-54 sun4u sparc... (2 Replies)
Discussion started by: superparticle
2 Replies
10. Shell Programming and Scripting
Dear Experts,
I am new to this forum. Thank you for moderator to allow me to join.
I have a question about automatic compression using sh and crontab
on an application which runs on the Suse Linux Server 11 SP4.
My question is how to compress every file in a directory into its own tar... (5 Replies)
Discussion started by: Steven_2975
5 Replies
LEARN ABOUT ULTRIX
uncompress
compress(1) General Commands Manual compress(1)
Name
compress, uncompress, zcat - compress and expand data
Syntax
compress [ -f ] [ -v ] [ -c ] [ -b bits ] [ name ... ]
uncompress [ -f ] [ -v ] [ -c ] [ name ... ]
zcat [ name ... ]
Description
The command reduces the size of the named files using adaptive Lempel-Ziv coding. Whenever possible, each file is replaced by one
with the extension .Z, while keeping the same ownership modes, access, and modification times. If no files are specified, the
standard input is compressed to the standard output. Compressed files can be restored to their original form using or
The -f option will force compression of name, even if it does not actually shrink name, or if the corresponding name .Z file
already exists. If the -f option is omitted, the user is asked whether an existing name.Z file should be overwritten (unless is
run in the background under
The -c (cat) option makes compress/uncompress write to the standard output without changing any files. Neither -c nor alter files.
The command uses the modified Lempel-Ziv algorithm. Common substrings in the file are first replaced by 9-bit codes 257 and up.
When code 512 is reached, the algorithm switches to 10-bit codes and continues to use more bits until the limit specified by the -b
flag is reached (default 16). The bits must be between 9 and 16. The default can be changed in the source to allow to be run on a
smaller machine.
After the bits limit is attained, periodically checks the compression ratio. If the ratio is increasing, continues to use the
existing code dictionary. However, if the compression ratio decreases, discards the table of substrings and rebuilds it from
scratch. This allows the algorithm to adapt to the next block of the file.
Note that the -b flag is omitted for since the bits parameter specified during compression is encoded within the output along with
a number that ensures that neither decompression of random data nor recompression of compressed data is attempted.
How much each file is compressed depends on the size of the input, the number of bits per code, and the distribution of common sub-
strings. Typically, text such as source code or English is reduced by 50-60%. Compression is generally much better than that
achieved by Huffman coding or adaptive Huffman coding, and takes less time to compute.
The -v option displays the percent reduction of each file.
If an error occurs, exit status is 1. However, if the last file was not compressed because it became larger, the status is 2.
Otherwise, the status is 0.
Options
-f Forces compression of name.
-c Makes compress/uncompress write to the standard output.
-b Specifies the allowable bits limit. The default is 16.
-v Displays the percent reduction of each file.
Diagnostics
Usage: compress [-fvc] [-b maxbits] [file ...]
Invalid options were specified on the command line.
Missing maxbits
Maxbits must follow -b.
file: not in compressed format
The file specified to uncompress has not been compressed.
file: compressed with xx bits, can only handle yy bits
The file was compressed by a program that could deal with more bits than the compress code on this machine. Recompress the file
with smaller bits.
file: already has .Z suffix -- no change
The file is assumed to be compressed already. Rename the file and try again.
file already exists; do you wish to overwrite (y or n)?
Type y if you want the output file to be replaced; type n if you do not.
uncompress: corrupt input
A SIGSEGV violation was detected which usually means that the input file is corrupted.
Compression: xx.xx%
Percent of the input saved by compression. (For the -v option only.)
-- not a regular file: unchanged
If the input file is not a regular file (for example, a directory), it remains unchanged.
-- has xx other links: unchanged
The input file has links; it is left unchanged. See for more information.
-- file unchanged
No savings is achieved by compression. The input remains unchanged.
Restrictions
Although compressed files are compatible between machines with large memory, -b12 should be used for file transfer to architectures
with a small process data space (64KB or less).
RISC compress(1)