22
9
I want to get a list of all available Network-Device Names on my Linux server. I figured that
ifconfig
would do the job, however ifconfig produces quite much output:
eth0 Link encap:Ethernet Hardware Adresse 08:00:27:fc:5c:98
inet Adresse:192.168.2.222 Bcast:192.168.2.255 Maske:255.255.255.0
inet6-Adresse: fe80::a00:27ff:fefc:5c98/64 Gültigkeitsbereich:Verbindung
UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1
RX packets:329 errors:0 dropped:0 overruns:0 frame:0
TX packets:177 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:1000
RX bytes:41496 (40.5 KiB) TX bytes:32503 (31.7 KiB)
eth1 Link encap:Ethernet Hardware Adresse 08:00:27:e9:35:7d
[...]
eth2 Link encap:Ethernet Hardware Adresse 08:00:27:ff:db:fe
[...]
lo Link encap:Lokale Schleife
[...]
What I want to achieve is a list like
eth0
eth1
eth2
lo
or even better just
eth0
eth1
eth2
I assume that this can be done by a combination of "cat", "sed" and "grep", but I have simply no clue of how to strip the uneccessary information.
I realize that Linux and BSD often contain different
*nixutilities, but it's unfortunate this solution doesn't work on a Mac :( – blong – 2016-09-24T12:54:05.983ifconfigis deprected, useipinstead – pstanton – 2018-02-26T01:22:32.710This seems to work for OS X:
ifconfig -a | sed -E 's/[[:space:]:].*//;/^$/d'– Paused until further notice. – 2018-02-26T03:57:54.887Thanks dennis, this worked like a charm^^. Perfekt. Regular Expressions are really something i should look into^^ – ftiaronsem – 2010-10-26T19:39:45.600