Skip to main content
2 of 3
added 386 characters in body
Faheem Mitha
  • 36.1k
  • 33
  • 129
  • 190

Much of the time, and probably in this case, just plain less will do the right thing. This uses the so-called less preprocessor. So, do

less file.sql.gz

This won't actually write the file in plain text to the filesytem; it is for your viewing pleasure only, but much of the time that is enough. I personally find the less preprocesor quite useful. It saves me from remembering a bunch of commands. On Debian, at least, the less preprocessor is /bin/lesspipe. This is a shell script.

The relevant part of this script for just a gzipped text file is:

                 # Note that this is out of alpha order so that we don't catch
                    # the gzipped tar files.
                    *.gz|*.z|*.dz)
                            gzip -dc "$1" ;;

This is with less version 444-4 on Debian wheezy.

Faheem Mitha
  • 36.1k
  • 33
  • 129
  • 190