I am struggling with a preseed-script for Debian and figured out that awk is not available in the installation process.
## A little context
The preseed-script fails at the following line and returns empty result:
real=ip -o link | awk '// {print $2;}' | sed s/://
cat /etc/network/interfaces
#loopback
auto lo
iface lo inet loopback
#
auto $real
allow-hotplug $real
iface $real inet
As result, $real
is empty and produces a faulty network configuration.
## What I hope to archive
I'd like to rewrite the command so that the result looks like ens18
or eth0
based on this input:
root@vm:~# ip -o link
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000\ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens18: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000\ link/ether 1e:7d:da:55:31:23 brd ff:ff:ff:ff:ff:ff
This is the command which is failing during installation:
root@vm:~# ip -o link | awk '/1e:7d:da:55:31:23/ {print $2;}' | sed s/://
ens18
## My question
How can I avoid awk
and work with other tools in this situation to get the interface-name like ens18
from ip -o link
-output? Unfortunately I am not that familiar with sed
.
Asked by SPQRInc
(105 rep)
Apr 14, 2021, 06:54 AM
Last activity: Apr 14, 2021, 07:09 AM
Last activity: Apr 14, 2021, 07:09 AM