Saturday, April 9, 2022

[SOLVED] How to find particular interface name and status from ifconfig command?

Issue

When I use ifconfig command, it will show the details of all active devices.

I want the interface name only, and want to check whether the interface is running or not.

ifconfig | grep interface-name  

This will give all detail about the interface but I want to print only interface name.


Solution

Since you have the interface name, you can do the following:

$ ifconfig interface-name &> /dev/null
$ echo $?

If the output is 0, the interface exists, otherwise, it doesn't.



Answered By - Maroun
Answer Checked By - Robin (WPSolving Admin)