Skip to content

Instantly share code, notes, and snippets.

@iflamed
Created Jun 14, 2021
Embed
What would you like to do?
获取linux/mac 主机IP地址
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v 169.254|grep -v 0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:" | head -n 1
@iflamed

This comment has been minimized.

Copy link
Owner Author

@iflamed iflamed commented Jun 14, 2021

export HOST_IP=ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v 169.254|grep -v 0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:" | head -n 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment