Eu sou novo no Linux e gostaria apenas de saber
- o que o
zcat comando fazer?
- Qual é a diferença entre eles?
- em que ocasião os usaríamos?
Isso realmente ajudaria se vocês pudessem dar alguns exemplos.
I am new to Linux and would just like to know
It would really help if you guys could give some examples.
Take a look at
You will see that they are the same:
On some systems, zcat may be installed as gzcat to preserve the original link to compress.
And what they do, which is uncompress a compressed archive and write the entire contents to stdout ie the terminal window.
This is rarely what you want.
$ ls -l Py* -rw-rw-r-- 1 zanna zanna 20566643 Aug 17 17:12 Python-3.5.2.tgz $ zcat Py* > huge-file $ wc huge-file 1859226 7277134 78458880 huge-file
However you might use it to read some old system logs that have been compressed like so:
$ sudo -i # zcat /var/log/dpkg.log.2.gz | less
But as @Serg points out, there is also
zless so this is a Useless Use of
# zless /var/log/dpkg.log.2.gz
You could also redirect (
>) the output to a file in these examples because it is so long. Then you could read it in your favourite text editor that allows easier scrolling and searching...
# zcat /var/log/dkpg.log.2.gz > old-dpkg-log
zcat leaves the original file alone and doesn't save a new file or directory, so it provides a way you can look inside an archive without creating any clutter.
You might find a good use for it in a script... :)
zcat is same thing as
uncompress -c, though on many systems it is actually same as
gzcat is same as
gunzip -c which is
man pages and available -options for:
Basically, if you have text files stores in archive files, like
.gz archive or
.zip file, those commands will print the textfiles without extracting them.
This is very useful for log files, since those files grow large and Linux automatically rotates them, periodically, by storing older ones into
open a terminal and use "man zcat" and/or "man gzcat". In a short term : "gzip, gunzip, zcat - compress or expand files"