Chad C. Walstrom writes: >On Fri, Feb 23, 2001 at 01:32:41PM -0300, Marcelo Chiapparini wrote: >> this is a very elemental question: how can I read a text file which >> is gzipped? Al documentation files are stored in this way... eg >> README.gz > >Why do people suggest using things like mc(1)? What if Marcelo hasn't >installed midnight commander? Let's instead suggest he learns about >the tools on the system instead of learning about crutches such as mc. > >Marcelo, *.gz files are compressed files created with the gzip(1) >tool. When you see people referring to an application like I referred >to gzip above, it means that there is a manpage -- aka manual page -- >available. You can view the manpage with the man(1) command. > >Now, go take a look at gzip(1), as gunzip(1) shows you the same >manpage. gunzip is a simple "wrapper" for > > bash$ gzip -cd <file.gz> > >The nice thing about shells and UNIX in general is that you can >redirect the input into pager's you're familiar with, such as more(1), >less(1), most(1), or even vi(1), my favorite editor. > > bash$ gzip -cd file.gz | more > >Notice the pipe ('|'). You can read about redirection of standard >input (stdin), standard output (stdout), and standard error (stderr), >in the manpage for the shell that you are using. Debian installs with >bash(1) as your default shell, so that would be a good place to start. > >Someone mentioned the use of zless. This is a way of calling less(1), >a popular pager, to automatically decompress the file. Essentially, >zless does the following: > > bash$ gzip -cd file.gz | less zless is a keystroke saver, but it only handles "*.gz" files. With the preprocessor feature of less it can be made to handle *.deb, *.bz2 and other compression types as well. A "lesspipe" script has been attached that can do these. Thus typing less <package>.deb will list the contents of the deb package. You will need to define the environmental variable "LESSOPEN", i.e., for csh|tcsh setenv LESSOPEN "| ~/bin/lesspipe %s" Of course "lesspipe" must be made excutable. > >Cool, huh? Say you want to email someone the uncompressed version of >that file. Given that you've set up sendmail(1), smail(1), or other >Mail Transfer Agent (MTA). You can do stuff like this: > > bash$ gzip -cd file.gz | mailx -s 'Here is the file...' friend@there.com > >And thus you see the beauty of the UNIX philosophy: "Everything is a >filter." > >The next place for you to look for information is in the document >directories: > > /usr/share/doc/<package> > >So go look there for stuff on: gzip, more, less, bash, etc... > >Have fun! > >-- >Chad Walstrom <chewie@wookimus.net> | a.k.a. ^chewie >http://www.wookimus.net/ | s.k.a. gunnarr >Key fingerprint = B4AB D627 9CBD 687E 7A31 1950 0CC7 0B18 206C 5AFD >
Attachment:
lesspipe
Description: lesspipe
-- Carl Greco cgreco@novia.net