systemadmin.es > Utilidades > Visualización de archivos comprimidos con zcat

Visualización de archivos comprimidos con zcat

Resulta común configurar logrotate para comprimir los ficheros de log para almacenarlos. Mediante zcat podemos visualizarlos sin descomprimirlos previamente.

Por ejemplo, usando estos ficheros:

# ls messages*
messages  messages.1.gz  messages.2.gz  messages.3.gz  messages.4.gz

Usamos zcat con los ficheros comprimidos:

# zcat messages.1.gz
Mar  8 05:53:46 shuVak freshclam[2091]: Received signal: wake up
Mar  8 05:53:46 shuVak freshclam[2091]: ClamAV update process started at Sun Mar  8 05:53:46 2009
Mar  8 05:53:46 shuVak freshclam[2091]: main.cld is up to date (version: 50, sigs: 500667, f-level: 38, builder: sven)
Mar  8 05:53:46 shuVak freshclam[2091]: daily.cld is up to date (version: 9080, sigs: 14111, f-level: 38, builder: neo)
Mar  8 05:53:46 shuVak freshclam[2091]: --------------------------------------

zcat sería equivalente a usar el comando gzip o gunzip con la opción -c:

# gzip -dc messages.1.gz
Mar  8 05:53:46 shuVak freshclam[2091]: Received signal: wake up
Mar  8 05:53:46 shuVak freshclam[2091]: ClamAV update process started at Sun Mar  8 05:53:46 2009
Mar  8 05:53:46 shuVak freshclam[2091]: main.cld is up to date (version: 50, sigs: 500667, f-level: 38, builder: sven)
Mar  8 05:53:46 shuVak freshclam[2091]: daily.cld is up to date (version: 9080, sigs: 14111, f-level: 38, builder: neo)
Mar  8 05:53:46 shuVak freshclam[2091]: --------------------------------------

En el caso de gunzip nos ahorramos la opción -d:

# gunzip -c messages.1.gz
Mar  8 05:53:46 shuVak freshclam[2091]: Received signal: wake up
Mar  8 05:53:46 shuVak freshclam[2091]: ClamAV update process started at Sun Mar  8 05:53:46 2009
Mar  8 05:53:46 shuVak freshclam[2091]: main.cld is up to date (version: 50, sigs: 500667, f-level: 38, builder: sven)
Mar  8 05:53:46 shuVak freshclam[2091]: daily.cld is up to date (version: 9080, sigs: 14111, f-level: 38, builder: neo)
Mar  8 05:53:46 shuVak freshclam[2091]: --------------------------------------

Deja un comentario:

XHTML - Tags permitidos:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>