标签:sed实例
touch 222.txt
[root@localhost /]# cat /old/222.txt
http://www.baidu.com
http://www.baidu.com
http://www.baidu.com
http://www.baidu.com
[root@localhost /]# find / -type f -name "222.txt"|xargs sed -i ‘s/http:\/\/www.baidu.com/www.xian.com/g‘
[root@localhost /]# cat /old/222.txt
www.xian.com
www.xian.com
www.xian.com
www.xian.com
[root@localhost /]# find / -type f -name "222.txt"|xargs sed ‘s/www.xian.com/http:\/\/www.baidu.com/g‘ (不加参数只是打印更改结果,实际内容未变)
http://www.baidu.com
http://www.baidu.com
http://www.baidu.com
[root@localhost /]# nl /old/222.txt|sed ‘2,3d‘ (删除2-3行)
1 http://www.baidu.com
4 http://www.baidu.com
[root@localhost /]# sed -n ‘1p‘ /old/222.txt (只打印第一行,不加-n都打印)
http://www.baidu.com
本文出自 “11812303” 博客,请务必保留此出处http://11822303.blog.51cto.com/11812303/1811645
标签:sed实例
原文地址:http://11822303.blog.51cto.com/11812303/1811645