Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A simple example is piping uncompressed data "on the fly" to a pager like more (or less):

Code Block
languagebash
titlePipe gunzip -c output to a pageruncompressed output to a pager
# zcat is like cat, except that it understands the gz compressed format,
# and uncompresses the data before writing it to standard output.
# So, like cat, you need to be sure to pipe the output to a pager if
# the file is large.
zcat big.fq.gz | more

# Another way to do the same thing is to use gunzip and provide# the -c option,
# which says to write decompressed data to the consolestdout (stdout-c for "console")
gunzip -c big.fq.gz | more

...

  • cat outputs all the contents of its input (one or more files and/or standard input) or the specified file
    • CAUTION – only use on small files!
  • zcat <file.gz> like cat, but understands the gzip (.gz)
    format, and decompresses the data before writing it to standard output
    • CAUTION – CAUTION - only use on small files!
    • Another CAUTION – does not understand .zip or .bz2 compression formats
  • more and less "pagers"
    • both display their (possibly very long) input one Terminal "page" at a time
    • in more, use spacebar to advance a page; q or Ctrl-c to exit more
    • in less:
      • q – quit
      • Ctrl-f or space – page forward
      • Ctrl-b – page backward
      • /<pattern> – search for <pattern> in forward direction
        • n – next match
        • N – previous match
      • ?<pattern> – search for <pattern> in backward direction
        • n – previous match going back
        • N – next match going forward
  • head and tail
    • show you the top or bottom 10 lines (by default) of their input
  • gunzip -c <file.gz> | more (or less) – uncompresses lines of <file.gz> and outputs them to standard output
    • <file.gz> is not altered on disk
    • always pipe the output to a pager!

...