List only the device names of all available network interfaces
Another alternative would be:
ip -o link show | awk -F': ' '{print $2}'
Or maybe:
ls /sys/class/net
Just use /sys/class/net and strip out the path:
$ basename -a /sys/class/net/*
eth0
eth1
lo
ppp0
tun0
A more modern way would be to use the iproute json output and a parser, like:
$ ip -j link |jq -r '.[].ifname'
lo
wlp0s20f3
enp0s31f6
virbr0
virbr0-nic
Which allows you to filter out the loopback interface:
$ ip -j link |jq -r '.[].ifname | select(. != "lo")'
wlp0s20f3
enp0s31f6
virbr0
virbr0-nic
Give this a try:
ifconfig -a | sed 's/[ \t].*//;/^$/d'
This will omit lo
:
ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'