Answer the question
In order to leave comments, you need to log in
Is there a lazy mode in AWK regular expressions?
The task in general is to get the name of the interface by specifying ip.
There is this conclusion:
1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:51:e9:32 brd ff:ff:ff:ff:ff:ff
3: [email protected]: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
18: [email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/sit 45.139.184.150 peer 209.51.161.14
19: [email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/sit 185.230.140.161 peer 184.105.250.46
20: [email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/sit 185.230.140.162 peer 209.51.161.14
21: [email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/sit 185.230.140.160 peer 216.66.84.46
18: [email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/sit 45.139.184.150 peer 209.51.161.14
19: [email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/sit 185.230.140.161 peer 184.105.250.46
20: [email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/sit 185.230.140.162 peer 209.51.161.14
21: [email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/sit 185.230.140.160 peer 216.66.84.46
21: [email protected]: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1480 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/sit 185.230.140.160 peer 216.66.84.46
Answer the question
In order to leave comments, you need to log in
$ ip -j l | jq -r '.[] | select(.address=="185.230.140.160") | .ifname'
$ ip -j l | jq -r '.[] | "\(.address) \(.ifname)"'
If necessary, be sure to use ip link show and awk:
ip link show | awk '/185.230.140.160/{print p $0; p=""; next} {p=$0 ORS}'
ip link show | grep -B1 185.230.140.160
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question