Linux 4 All

Best Linux tricks source

For this, we are going to use egrep with -o option to print only the matched parts and not the entire line.

-o, –only-matching
Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.

Below there are 2 examples:

egrep -o "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" $LOGFILE
egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" $LOGFILE

Restore file permissions and ownership using ACL arrow-right
Next post

arrow-left Configure APC module
Previous post

Leave a Reply

Your email address will not be published. Required fields are marked *