在 linux 上检索 eth0 ipv6 地址

use*_*248 2 linux scripting ip-address ipv6 ifconfig

我希望在我的一个 shell 脚本中使用我的 eth0 ipv6 地址。我可以使用 ifconfig 和 grep 来检索它,但我确定它一定在某个我没有看到的文本文件中的某个地方,这最终会使检索变得更加容易。有谁知道我应该在哪里看?

谢谢

Ans*_*ers 5

ip addr show eth0 | awk '/inet6/ {print $2}'
Run Code Online (Sandbox Code Playgroud)