Web Development

/ 1评 / 0/ 最后更新:2020-04-04
mac查看本机ip地址

需求场景

身为程序员,很多时候需要知道本地的ip地址,比如本机web服务器同事想要访问,就需要知道ip地址。手机charles调试,电脑端作为代理需要知道ip地址以及端口。

解决方案

博主之前都会采用ifconfig命令查看地址,每次都需要仔细的找才能看到ip地址。现在才知道其实可以用grep命令辅助我们快速找到ip地址

ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'

优化

如果每次都要这样写就太麻烦了。建议加入alias中

alias ip="ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print \$2}'"
0
  1. Adoncn says:

    多谢好文章,多些这种文章真不错

Leave a Reply

Your email address will not be published. Required fields are marked *