#!/bin/sh # Vpn IP # seperate with _ and : , see `man awk.1p` "Otherwise, the string value of FS # shall be considered to be an extended regular expression. ...", so -F if # multiple chars means it is regex? so [_:] inside [] there's _ and : char # which in regex means _ and : char? More maybe see: # https://www.gnu.org/software/gawk/manual/html_node/Regexp-Field-Splitting.html nmcli -t --fields device,state device | awk -F'[_:]' '/wg_.*:connected/{print $2}' printf 'default: '; curl -m1 ifconfig.co printf '4: '; curl -4m1 ifconfig.co printf '6: '; curl -6m1 ifconfig.co