Skip to main content
added 350 characters in body
Source Link

Previous answers suggested:

ifconfig: which is deprecated.

ip -s link: which doesn't display all the information that ifconfig displays (such as IP address).

I wanted to offer another command that worked for me. So if you're looking for IP address(es) of an interface, you might consider:

For the raw interface output:

ip a | grep s1 -A3

For IPv4 only:

ip -4 a | grep s1 -A1

ip a is an abbrevation for ip address. -A1 and -A3 paremeters determine the number of lines to display after the last occurrence of your text. If you modify the parameters in ip command, you can change the -A parameter's number to fit as well.

For the raw interface output:

ip a | grep s1 -A3

For IPv4 only:

ip -4 a | grep s1 -A1

-A1 and -A3 paremeters determine the number of lines to display after the last occurrence of your text. If you modify the parameters in ip command, you can change the -A parameter's number to fit as well.

Previous answers suggested:

ifconfig: which is deprecated.

ip -s link: which doesn't display all the information that ifconfig displays (such as IP address).

I wanted to offer another command that worked for me. So if you're looking for IP address(es) of an interface, you might consider:

For the raw interface output:

ip a | grep s1 -A3

For IPv4 only:

ip -4 a | grep s1 -A1

ip a is an abbrevation for ip address. -A1 and -A3 paremeters determine the number of lines to display after the last occurrence of your text. If you modify the parameters in ip command, you can change the -A parameter's number to fit as well.

Source Link

For the raw interface output:

ip a | grep s1 -A3

For IPv4 only:

ip -4 a | grep s1 -A1

-A1 and -A3 paremeters determine the number of lines to display after the last occurrence of your text. If you modify the parameters in ip command, you can change the -A parameter's number to fit as well.