I want to see how many interfaces(ethernet cards) are
working using single command?

Answer Posted / alf55

The command:

ifconfig -a | (grep -E 'Link encap:|inet6 addr|inet addr:' |
grep -vE 'inet addr:|inet6 addr')

Would result with an output similar to:

eth0 Link encap:Ethernet HWaddr 00:90:f5:b7:6a:1c
lo Link encap:Local Loopback
sit0 Link encap:IPv6-in-IPv4
wlan0 Link encap:Ethernet HWaddr 00:24:d7:a7:16:c0

So the command:

ifconfig -a | (grep -E 'Link encap:|inet6 addr|inet addr:' |
grep -vE 'inet addr:|inet6 addr') | wc -l

would produce the count.

The problem here is that it would also count usages such as
"eth0:0".

To not count those devices use:

ifconfig -a | (grep -E 'Link encap:|inet6 addr|inet addr:' |
grep -vE 'inet addr:|inet6 addr:|:[0-9][0-9]*') |wc -l

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain getopts command of linux?

587


How do you run command every time a file is modified?

533


What is mkdir p?

560


What is the difference between rmdir and rm r?

618


What does the ps command do in linux?

529






What is the difference between locating and locate command?

525


What is ps command in linux?

543


What is a good processor speed?

515


What are whois tools?

520


what do know about commands?

578


How do I check memory usage on linux?

560


How do I check dns entry?

556


The head command writes the how many lines of a file to screen?

547


How often do you use grep command and how in Linux operating system?

531


What is build process?

563