您的位置:首页 > 运维架构 > Shell

shell命令使用技巧

2012-07-13 00:00 337 查看
获取本机ip的一个正则表达式

ipconfig |grep 'inet addr' | grep 'Bcast' |sed s/.*addr://g |sed s/Bcast.*$//g

分析:

1、ipconfig | grep ‘inet addr’| grep 'Bcast'

将ip地址所在行过滤出来

2、ipconfig |grep 'inet addr' | grep 'Bcast' |sed s/.*addr://g

将 ip地址前的信息用空代替 (sed s/word1/word2/g 用word2替换word1,".*"表示任意字符串)

3、自己分析最后一步

获取进程的pid

ps aux | grep 'process' | grep -v 'grep' |awk '{print $2}'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell