LINUX - List only the device names of all available network interfaces
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
I want to get a list of all available Network-Device Names on my Linux server. I figured that
netstat -a
would do the job, however netstat 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.
Thanks in advance
This question and answers originated from www.superuser.com
Question by ftiaronsem (10/25/2010 8:41:03 PM)
Answer |
Give this a try:
ifconfig -a | sed 's/[ \t].*//;/^$/d'
This will omit lo:
ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'
Answer by Dennis Williamson
Find More Answers
Related Topics linux networking sed grep cat