On Fri, Apr 23, 2021 at 09:59:09PM -0500, David Wright wrote: > OTOH my startup files set Mywiredifname for scripts to use, where: > > Mywiredifname=$(ip -o link show | sed -e '/^[0-9]\+: [^e]/d;s/[0-9]\+: > \([^:]\+\): .*/\1/;q') > > $ echo $Mywiredifname > enp3s0
unicorn:~$ ip -o link show | awk -F': ' '{print $2}' lo lan0 You're relying on the "default" names which ensure that an ethernet interface begins with an 'e', so we could fold that in as well: ip -o link show | awk -F': ' '$2 ~ /^e/ {print $2}' It's slightly prettier than yours, and doesn't rely on GNUisms (which are probably not a big issue since a system with "ip" probably has GNU sed). > (My days of running multiple ethernet cards are long gone, > so sed will quit after one match.) Sounds like a naive assumption. Some motherboards have dual NICs built in, don't they?