LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 941|回复: 2

如何搞定 ip 地址的简单输出?

[复制链接]
发表于 2005-1-2 17:04:30 | 显示全部楼层 |阅读模式
我希望运行一个命令后,只是显示其 ip 地址,可是 ifconfig ppp0 却输出一大串。

我只希望:

# show_ip ppp0
1.2.3.4
(show_ip 为我假想的命令。)

即可,请问哪位老大有如此研究?
发表于 2005-1-2 19:52:00 | 显示全部楼层
/etc/ppp/ip-up文件有给用户留一个接口,其中有一个接口就是当前IP地址的
 楼主| 发表于 2005-1-2 20:41:42 | 显示全部楼层
搞定了:
  1. 2005年01月02日星期日下午20时43分18秒[root@mail lootan]# ifconfig ppp0|grep "inet addr" | cut -f2 -d:| cut -f1 -d" "
  2. 219.133.152.215
  3. 2005年01月02日星期日下午20时43分21秒[root@mail lootan]# ifconfig eth0|grep "inet addr" | cut -f2 -d:| cut -f1 -d" "
  4. 192.168.0.1
复制代码
:cool:  :cool:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表