Compressing and decompressing files

Contents

Compressing and decompressing files#

Files can be compressed to take up less space on the hard drive (disk), or for transfer over the internet. The file you downloaded is an example, and we can decompress it using the gunzip command:

# Decompress a file
gunzip GCF_000482265.1_EC_K12_MG1655_Broad_SNP_genomic.fna.gz

If you ever need to compress a file, for instance to send it to someone, you can use the gzip command:

# Compress a file
gzip GCF_000482265.1_EC_K12_MG1655_Broad_SNP_genomic.fna

Exercise 1.10#

Exercise 1.10

  • Decompress the downloaded file from the last exercise.

# Decompress it
gunzip GCF_000482265.1_EC_K12_MG1655_Broad_SNP_genomic.fna.gz

# Check that the file ending changed from .fna.gz (compressed) to .fna (uncompressed)
ls
  • Compress the downloaded file again (since it is always good practice to keep big files in compressed form to save storage space).

# Compress it again
gzip GCF_000482265.1_EC_K12_MG1655_Broad_SNP_genomic.fna

# Check the ending .gz of the file to see that it is compressed
ls