Sponsored Content
Top Forums Shell Programming and Scripting what is the difference between commands compress, pack and gzip Post 302558575 by h@foorsa.biz on Saturday 24th of September 2011 05:26:03 AM
Old 09-24-2011
Yes in some ways they are the same functionality they intend to compress data.
Some do better than others e.g gzip is better than compress and pack in overall .

compress and gzip are alike in some ways as they are exploit the same algorithm but they differ in some ways.

compress : The compress utility will attempt to reduce the size of the named files by using adaptive Lempel-Ziv coding. Typically, text such as source code or English is reduced by 50-60%. Compression is generally much better than that achieved by Huffman coding (as used in pack ).

pack : The pack command attempts to store the specified files in a compressed form. Wherever possible (and useful), each input file file is replaced by a packed file file.z with the same access modes, access and modified dates, and owner as those of file. If pack is successful, file will be removed.

gzip Is a GNU version of Lempel-Ziv coding (LZ77) which reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension ‘.gz’, while keeping the same ownership modes, access and modification times.
This User Gave Thanks to h@foorsa.biz For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compress --> gzip

I have hundreds of ".Z" files that I need to uncompress and gzip. I'm not sure how to handle this in a 'for loop'. I can get the uncompress part, but I'm not sure how to strip the .Z off the filename for the gzip step. Is it possible to pipe the output of uncompress to gzip? (2 Replies)
Discussion started by: 98_1LE
2 Replies

2. UNIX for Dummies Questions & Answers

compress and descompress file whit pack

hi i dont can traspassing file from unix sco compress whit pack or compress i dont can descompress whit other program... how i can do descompress that file in windows me.??? thank very much... pd:sorry my inglish (6 Replies)
Discussion started by: jtapia
6 Replies

3. SCO

compress & cpio commands

Our End of Day backup routine uses following script. start End-of-day compress $BASE TO /home/compdir write /home/compdir to DATTAPE end where $BASE=/home2/Rev83 DATATAPE=/dev/rmt/ctape1 write=cpio (not sure about parameters) since I'm new to UNIX, i dont know how to restore data... (1 Reply)
Discussion started by: tayyabq8
1 Replies

4. UNIX for Dummies Questions & Answers

SSH Compress Commands

I am brand new to unix and am hoping someone can start me in the right direction. I hope I have the right forum but if not can a moderator move this thread to the right area. I am moving servers and need to back up a folder and its sub folders into a .tar.gz file then want to upload that file... (2 Replies)
Discussion started by: kushti
2 Replies

5. UNIX for Dummies Questions & Answers

difference between 'compress' and 'gzip'

hi can i know the diff between these 2 commands in terms of data compressed (3 Replies)
Discussion started by: anandapani
3 Replies

6. UNIX for Dummies Questions & Answers

perl pack and unpack commands

I have a file that contains user id and corresponding password. Lets say password is "help". The below command will create a hex value for string "help". perl -e 'print unpack "H*","help"' So now password is in encoded format. Then I decoded it in the script where am fetching the... (1 Reply)
Discussion started by: max_payne1234
1 Replies

7. UNIX for Dummies Questions & Answers

gzip instead of compress

Duplicate threads merged jmc Hi, I have a script wherein I want to use gzip instead of compress. # cat dly_appsfiles_bkp.ksh # # dly_appsfiles_bkp.ksh # date_stamp=`date +%m%d%y` base_dir=/u05/gld1 sub_dir=apps bkp_dir=/u00/backup/GLD1/APPS... (5 Replies)
Discussion started by: narayanv
5 Replies

8. UNIX for Advanced & Expert Users

limitation of gzip and compress

Hi, in AIX 6.1 what is the limite of gzip and compress ? I mean what can be at most the size of the file to compress ? Thank you. (1 Reply)
Discussion started by: big123456
1 Replies

9. UNIX for Dummies Questions & Answers

perl pack and unpack commands

I am using pack/unpack to encyrpt a file. syntax is below #!/bin/sh encrypt=`perl -e 'print unpack "H*","yourpassword"'` - echo $encrypt >/file/to/store/encrypted/password pass=`cat /file/to/store/encrypted/password` decrypt=`perl -e 'print pack "H*",$pass'` ... (2 Replies)
Discussion started by: erinlomo
2 Replies

10. UNIX for Beginners Questions & Answers

Compress multiple gzip files

Good afternoon friends. I wanted to make a query, how to compress several files and leave them all in 1, for example flat text files: filename_1.csv filename_2.csv filename_3.csv expected result filename_end.gzip = (filename_1.csv filename_2.csv filename_3.csv) please (2 Replies)
Discussion started by: tricampeon81
2 Replies
COMPRESS(1)						    BSD General Commands Manual 					       COMPRESS(1)

NAME
compress, uncompress -- compress and expand data SYNOPSIS
compress [-fv] [-b bits] [file ...] compress -c [-b bits] [file] uncompress [-f] [file ...] uncompress -c [file] DESCRIPTION
The compress utility reduces the size of files using adaptive Lempel-Ziv coding. Each file is renamed to the same name plus the extension .Z. A file argument with a .Z extension will be ignored except it will cause an error exit after other arguments are processed. If compres- sion would not reduce the size of a file, the file is ignored. The uncompress utility restores compressed files to their original form, renaming the files by deleting the .Z extensions. A file specifica- tion need not include the file's .Z extension. If a file's name in its file system does not have a .Z extension, it will not be uncompressed and it will cause an error exit after other arguments are processed. If renaming the files would cause files to be overwritten and the standard input device is a terminal, the user is prompted (on the standard error output) for confirmation. If prompting is not possible or confirmation is not received, the files are not overwritten. As many of the modification time, access time, file flags, file mode, user ID, and group ID as allowed by permissions are retained in the new file. If no files are specified or a file argument is a single dash ('-'), the standard input is compressed or uncompressed to the standard output. If either the input and output files are not regular files, the checks for reduction in size and file overwriting are not performed, the input file is not removed, and the attributes of the input file are not retained in the output file. The options are as follows: -b bits The code size (see below) is limited to bits, which must be in the range 9..16. The default is 16. -c Compressed or uncompressed output is written to the standard output. No files are modified. The -v option is ignored. Compression is attempted even if the results will be larger than the original. -f Files are overwritten without prompting for confirmation. Also, for compress, files are compressed even if they are not actually reduced in size. -v Print the percentage reduction of each file. Ignored by uncompress or if the -c option is also used. The compress utility uses a 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 option or its default is reached. After the limit is reached, compress periodically checks the compression ratio. If it is increasing, compress continues to use the existing code dictionary. However, if the compression ratio decreases, compress discards the table of substrings and rebuilds it from scratch. This allows the algorithm to adapt to the next "block" of the file. The -b option is unavailable for uncompress since the bits 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. The amount of compression obtained depends on the size of the input, the number of bits per code, and the distribution of common substrings. Typically, text such as source code or English is reduced by 50-60%. Compression is generally much better than that achieved by Huffman cod- ing (as used in the historical command pack), or adaptive Huffman coding (as used in the historical command compact), and takes less time to compute. EXIT STATUS
The compress and uncompress utilities exit 0 on success, and >0 if an error occurs. The compress utility exits 2 if attempting to compress a file would not reduce its size and the -f option was not specified and if no other error occurs. SEE ALSO
gunzip(1), gzexe(1), gzip(1), zcat(1), zmore(1), znew(1) Welch, Terry A., "A Technique for High Performance Data Compression", IEEE Computer, 17:6, pp. 8-19, June, 1984. STANDARDS
The compress and uncompress utilities conform to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
The compress command appeared in 4.3BSD. BUGS
Some of these might be considered otherwise-undocumented features. compress: If the utility does not compress a file because doing so would not reduce its size, and a file of the same name except with an .Z extension exists, the named file is not really ignored as stated above; it causes a prompt to confirm the overwriting of the file with the extension. If the operation is confirmed, that file is deleted. uncompress: If an empty file is compressed (using -f), the resulting .Z file is also empty. That seems right, but if uncompress is then used on that file, an error will occur. Both utilities: If a '-' argument is used and the utility prompts the user, the standard input is taken as the user's reply to the prompt. Both utilities: If the specified file does not exist, but a similarly-named one with (for compress) or without (for uncompress) a .Z exten- sion does exist, the utility will waste the user's time by not immediately emitting an error message about the missing file and continuing. Instead, it first asks for confirmation to overwrite the existing file and then does not overwrite it. BSD
May 17, 2002 BSD
All times are GMT -4. The time now is 12:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy