shell命令使用技巧

获取本机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)