Inspecting gziped files without decompressing (entirely)

16 Apr

As part of some RNA-seq analysis I’ve been doing lately, I’ve been working a lot with compressed (gzip) files. Sometimes it’s handy to know what format the files are in. Of course, extracting a 2 gb file just to inspect what is actually in the file is annoying, so I needed a way to inspect the first few lines.

Since we’re working on linux for our bioinformatic analysis, the bash command below will decompress (-d) the file “filename” and write the contents to the shell (-c). This is then piped (|) into the head program to display the first few lines:


gzip -d -c filename | head

# options from gzip -h
# -d, --decompress decompress
# -c, --stdout write on standard output
# replace filename with your file

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.