🖥️egrep
➡️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 egrep command with important options and switches using examples.
3 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ███████╗ ██████╗ ██████╗ ███████╗██████╗
# ██╔════╝██╔════╝ ██╔══██╗██╔════╝██╔══██╗
# █████╗ ██║ ███╗██████╔╝█████╗ ██████╔╝
# ██╔══╝ ██║ ██║██╔══██╗██╔══╝ ██╔═══╝
# ███████╗╚██████╔╝██║ ██║███████╗██║
# ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝
egrep
Extended grep
The egrep command uses fancier regular expressions than the grep command. Many people use the egrep command for its internal algorithms, which are more sophisticated than the grep and fgrep commands. Also, the egrep command is usually the fastest of the three programs.
egrep -o "from=<[^>]+\.[a-z0-9-]{2,}>" /var/log/maillog |awk -F\. '{print $NF}' |sort |uniq -c |sort -rn |head -20
# .Top 20 email From TLDs
egrep -wo "(Donnie|Frank|Roberta|Grandma)" story.txt |sort|uniq -c|sort -r
# Search for names and build a frequency count for each name.
egrep -oi '#[a-f0-9]{6}' file.css | sort | uniq
# extract all unique hex color codes from a CSS file /cc
egrep -v "^#|^$" httpd.conf
# display the httpd.conf file contents and exclude blank lines and lines that start with comment character.
egrep -o '\b[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\b' /var/log/apache2/access.log | sort -u
# Display IPs accessing your Apache webserver.
egrep "^lease" /var/lib/dhcp/db/dhcpd.leases |awk '{ print $2 }'
# get IPs with a DHCP lease
# You can use that to create a excludefile for nmap, to find hosts, with no DHCP lease in your DHCP range.
egrep -i "@[a-z\.-]+\.[a-z]{2}\>" emails.txt
# Find email addresses with 2 letter TLDs in them. \> matches empty string at end of a word.
#==============================##==============================#
# CMD EGREP #
#==============================##==============================#
egrep -- "\t-\t-\t-\t-\t" entries.txt |sort -k3V
# Get the entries with 4+ null fields and sort the entries by IPv4 (-V) in the 3rd column.
egrep -v '(Teardown|Built)' *.log
# Kommentarzeilen ausblenden
egrep -v'^\s*(#|$)' /etc/squid3
egrep = "Extended GREP"
egrep uses fancier regular expressions than grep. Many people
use egrep all the time, since it has some more sophisticated
internal algorithms than grep or fgrep, and is usually the
fastest of the three programs.
tail -f "foo.log"|egrep --line-buffered --color=auto 'ERROR|WARN|CRITICAL$'
# tail foo.log & highlight errors and warnings (if your grep supports --color)
last -da | egrep -v "^(root|reboot|asmith) "
# See the last logged in users, but filter out entries for root, reboots and asmith.
egrep -v "^#|^$" httpd.conf
# display the httpd.conf file contents and exclude blank lines and lines that start with comment character.
egrep "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])" tmp | awk -F"," '{split($2,name,".");printf("%s;%s\n",$1,name[1])}' | sort -t";" -k2,2 | uniq > hardware_sorted.tmp
# egrep for fail logins
egrep "Failed|Failure" /var/log/auth.log
#==============================##==============================#
# CMD EGREP #
#==============================##==============================#
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 egrep in a clear format. This allows users to quickly access the needed information for egrep without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for egrep 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.