8.5 Exercises

8.5.1 Zipping

See Section 12.0.11 for solutions.

  1. Look at the file BanthracisProteome.txt using more and less

  2. Create a new file ‘short.txt’ containing the first 200 lines of BanthracisProteome.txt. Then, zip the file.

  3. To the same thing as in exercise 2 without every writing the file ‘short.txt’

  4. Extract the first 100 lines from the zipped file ‘short.txt.gz’ and store them in a new zipped file ‘shorter.txt.gz’, without ever unzipping ‘short.txt.gz’

  5. Create new files ‘Line1.txt’, ‘Line2.txt’, …, each containing only one line of ‘short.txt.gz’ without unzipping the file (Hint: use a while loop)

  6. Combine the 100 files ‘Line1.txt’, ‘Line2.txt’, … to a zipped archive called ‘all.tar’

  7. Now zip all ‘Line1.txt’, ‘Line2.txt’, … files individually and combine them to a new archive ‘zipped.tar’ without further zipping. Compare the sizes of the two archives.

  8. Crate a directory ‘all’, copy the archive ‘all.tar’ there and extract it.

  9. Clean up by deleting all Line* files, all archive files and the directory all with one command.