How can I extract to a variable
both the address (IPv4 or IPv6)
and the [number]
with grep
from ufw status numbered
?
Without using regex
to find the IP.
$ufw status numbered | grep -w 'DNS1'
[277] 53 ALLOW 216.218.130.2 # DNS1
$ufw status numbered | grep -w 'DNS2'
[288] 53 ALLOW 2001:470:100::2 # DNS2