I need to find those ethernet interfaces, which are up.
I tried this:
$ ip -d -j a s | jq 'map(select ((.link_type == "ether") and (.flags[] | contains
("UP")))) | map(.ifname)'
But it returns two results,
[
"enp0s3",
"enp0s3"
]
although ip lists this interface only once.
$ ip -d -j a s | jq 'map(.ifname)'
[
"lo",
"enp0s3",
"enp0s8"
]
It seems to me that the and in the select behaves like an or. It returns those interfaces, which have .link_type = "ether" or .flags[] | contains ("UP").
But when I try the same with a more basic example,
$ jq 'map(select((. > 1) and (. < 3)))' <<<'[1, 2, 3]'
it works as expected:
[
2
]
What did I wrong?