标签:
1.使用正则匹配文件名
## grep -n ‘[^\/][a-zA-Z0-9]*[.a-zA-Z0-9][a-zA-Z0-9]*$‘ regular_express.txt
/etc/init.d/hello.h
/etc/init.d/hehe
2.使用sed提取出网卡IP
(1)
# ifconfig eth0 |grep ‘inet addr‘
inet addr:192.168.211.129 Bcast:192.168.211.255 Mask:255.255.255.0
(2)
# ifconfig eth0 |grep ‘inet addr‘ | sed ‘s/^.*addr://g‘
192.168.211.129 Bcast:192.168.211.255 Mask:255.255.255.0
(3)
# ifconfig eth0 |grep ‘inet addr‘ | sed ‘s/^.*addr://g‘ | sed ‘s/Bcast.*$//g‘
192.168.211.129
3.
(1)过滤‘MAN‘
# cat /etc/man.config |grep -n ‘MAN‘
(2)将以#开头的句子后面内容替换为空
# cat /etc/man.config |grep -n ‘MAN‘ | sed ‘s/#.*$//g‘
11:
17:
18:
19:
39:
41:
43:MANPATH /usr/man
44:MANPATH /usr/share/man
45:MANPATH /usr/local/man
46:MANPATH /usr/local/share/man
47:MANPATH /usr/X11R6/man
(3)删除空行
# cat /etc/man.config |grep ‘MAN‘|sed ‘s/#.*$//g‘ | sed ‘/^$/d‘
MANPATH /usr/man
MANPATH /usr/share/man
MANPATH /usr/local/man
MANPATH /usr/local/share/man
MANPATH /usr/X11R6/man
标签:
原文地址:http://my.oschina.net/CentralD/blog/473050