Grep and Filter IP Address In Linux

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/grep-and-filter-ip-address-in-linux/
PINTEREST
PINTEREST
INSTAGRAM

Searching IP address in a text file or a console output may become cumbersome. This little command named grep will help you in this way.

Example Data

We have a file or output which includes IP address and we want to extract just IP addresses nothing other. This file is created with a nmap scan.

Print Interfaces IP Addresses

We can use ip addr command which will print current system interfaces and related information. We can grep from this information and print only IP addresses currently system is using with the following command.

Print Interfaces IP Addresses
Print Interfaces IP Addresses

Print Only IP Addresses

Here we use grep command and give -o option to only get IP address. The default behavior of the grep is printing lines which match given regex but if we only want to print matched text not the whole line we will use -o option which will print only IP addresses.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/grep-and-filter-ip-address-in-linux/
PINTEREST
PINTEREST
INSTAGRAM
LEARN MORE  How To List All Repository Packages With Yum