Grep tips

Date:2014-10-28

Extract all IPs from a file, regardless of the formatting

grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' file | sort -u

Extract all Emails from a file, regardless of the formatting

grep -Po "[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+"

Find services that have libs which have been updated and need restart

lsof | grep 'DEL.*lib'|awk '{print $1}'|sort -u

Grep stuff easily through SQL dumps

grep "stuff" sqldump.sql | fold -w 200 | grep -C 1 "stuff"