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

What does df command do in linux?

548


What does rmdir do in linux?

541


What does chmod 777 do?

590


You want to verify which lines in the file kickoff contain ‘bob’. Which of the following commands will accomplish this?

587


What is the difference between command ‘ping’ and ‘ping6’?

532






Which command is used to see the online manual?

610


Which command will show you free/used memory?

560


What does cd do in linux?

655


How can we increase disk read performance in single command in Linux?

567


What is make command in linux?

550


How do I check memory usage on linux?

566


How lilo is useful in linux?

573


Is llvm a compiler?

546


What the command used for search file or files for specific text?

501


Which command would you use if you want to remove the password assigned to a group?

528