🖥️zcat
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the zcat command with important options and switches using examples.
3 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███████╗ ██████╗ █████╗ ████████╗
# ╚══███╔╝██╔════╝██╔══██╗╚══██╔══╝
# ███╔╝ ██║ ███████║ ██║
# ███╔╝ ██║ ██╔══██║ ██║
# ███████╗╚██████╗██║ ██║ ██║
# ╚══════╝ ╚═════╝╚═╝ ╚═╝ ╚═╝
zcat dump.sql.gz | sed -n '5000,7500p' > newdump.sql
# Put lines 5000 through 7500 from a large compressed SQL file into a new file.
zcat access_log*.gz |cat - access_log |awk '{print $7}' |sed 's/\?.*//' |sort|uniq -c|sort -nr
# Get list of top URLs from all logs combined
zcat 2016-05-23/smtp.*.gz |awk '$1~/^[0-9]{9}/' |grep -v -e 10.1.2.3 -e root@
# Read compressed logs, process only time lines and filter.
zcat *access_log*.gz |cat - *access_log* |awk '$9==400||$9==413{print $1}' |sort |uniq
# Show remote hosts who received HTTP 400s or 413s
zcat large.log.gz |awk '{print $0 | "gzip -v9c > large.log-"$1"_"$2".gz"}'
# Breakup compressed log by syslog date and recompress.
zcat /var/log/syslog* | grep CRON
#
zcat /boot/initrd.img-$(uname -r) | cpio -idmv
#
zless, zgrep, zcat, zdiff
# There are helper commands for dealing with compressed files (gz, bz2 and xz). They have a z, bz or xz prefix.
zcat /var/log/fail2ban*gz | tee /var/log/fail2ban.log | tee /var/log/fail2ban.log.1 | grep Ban|cut -f7 -d" "|sort |uniq -c|sort -n
# sorted list of banned Ips
# Breakup large log by syslog month/day and recompress.
zcat month.log.gz | awk '{print $0 | "gzip -v9c > brokenup.log-"$1"_"$2".gz"}'
# Show MAC address lines when they first showed up over past year
zcat dhcp.log.{12..1}.gz |cat - dhcp.log |awk '/DHCPREQUEST/ && !a[$10]++'
zcat access_log*.gz |cat - access_log |awk '{print $7}' |sed 's/\?.*//' |sort|uniq -c|sort -nr
# Get list of top URLs from all logs combined
# Grepping two patterns in a large file cc
zcat large_file.gz | tee >(grep -F patternA > A-matches) >(grep -F patternB > B-matches) > /dev/null
# How many people is this likely to disturb if I mess up the certificate renewal.
zgrep -P "imapd: LOGIN, user=[^,]+, ip=\[::ffff:127.0.0.1\], port=\[[0-9]+\], protocol=IMAP" maillog-2019*.gz maillog | awk '{print $7}' | sort | uniq -c
#==============================##==============================#
# CMD ZCAT
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command zcat in a clear format. This allows users to quickly access the needed information for zcat without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for zcat are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.