The goal of this is to delete the existing connection name and create the new connections "ABC" "DEF" "GHI" and map to existing device(excluding lo).
#!/bin/bash
conname=$(nmcli con | awk ' $1 !~ "NAME|lo"{print $1}')
ifname=$(nmcli dev | awk ' $1 !~ "DEVICE|lo"{print $1}')
echo $conname
echo $ifname
The above returns following values:
test3 test4 test5
enp0s3 enp0s8 enp0s9
How can I produce following command lines by using previous output by awk
nmcli con del test3
nmcli con del test4
nmcli con del test5
The following is to create new connection names "ABC", "DEF", "GHI" which are mapped to interfaces "enp0s3" "enp0s8" "enp0s9". These interfaces were identified by awk. New connection names are fixed names.
nmcli con add type ethernet con-name ABC ifname enp0s3
nmcli con add type ethernet con-name DEF ifname enp0s8
nmcli con add type ethernet con-name GHI ifname enp0s9
I hope this is clearer.
*s in the output?