CS 742 - Compress files 1. This is an example of using a Huffman code to compress a file. We start by creating a file called "tempfile": $ ls -l tempfile -rw-r--r-- 1 chang csprof 165 Dec 3 22:47 tempfile $ cat tempfile aaaaaaaaaa bbbbbbbbbb bbbbbbbbbb cccccccccc cccccccccc cccccccccc dddddddddd dddddddddd dddddddddd dddddddddd eeeeeeeeee eeeeeeeeee eeeeeeeeee eeeeeeeeee eeeeeeeeee Note that the file contains: 10-a's 20-b's 30-c's 40-d's 50-e's 15- that you can't see. That is a total of 165 bytes. 2. Next, execute the gzip command to create a compressed file called tempfile.gz. $ gzip tempfile 3. Check the size of the new file: $ ls -l tempfile.gz -rw-r--r-- 1 chang csprof 51 Dec 3 22:47 tempfile.gz 4. Now, use a hex dumper to inspect the compressed file: $ hexdump -C tempfile.gz 00000000 1f 8b 08 08 e2 88 ed 3d 00 03 74 65 6d 70 66 69 |.......=..tempfi| 00000010 6c 65 00 4b 4c 84 01 ae 24 38 40 66 26 c3 01 0e |le.KL...$8@f&...| 00000020 66 0a 1c 10 66 a6 c2 01 49 4c 00 64 ab f9 8e a5 |f...f...IL.d....| 00000030 00 00 00 |...| 00000033 5. Uncompress the file using gunzip $ gunzip tempfile.gz