免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1027 | 回复: 0
打印 上一主题 下一主题

linux批量修改文件内容 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-07-14 15:27 |只看该作者 |倒序浏览

脚本目的:把一个目录下所有php文件中的 Louis/Site.css 改成 louis/site.css
1.       进入php文件目录
cd /home/sofialeather.com/public_html/
2.       查找出包含Louis/Site.css 的所有文件名(该步骤不用操作,脚本中有的)
[root@webhosting3 public_html]# find -name "*.dwt" -exec  awk '/Louis\/Site.css/{print FILENAME}' {} \;
./ec/themes/default-ppg1/library/index.dwt
./ec/themes/default-ppg1/index.dwt
./ec/themes/default-ppg1/article.dwt
./ec/themes/default-ppg1/category.dwt
./ec/themes/default-ppg1/user_passport.dwt
./ec/themes/default-ppg1/search.dwt
./ec/themes/default-ppg1/goods.dwt
./ec/themes/cyfanke/library/goods.dwt
./ec/themes/cyfanke/goods.dwt
./js/goods.dwt
./themes/default-ppg2/user_clips.dwt
./themes/default-ppg2/article6.dwt
./themes/default-ppg2/user_transaction.dwt
./themes/default-ppg2/library/user_clips.dwt
./themes/default-ppg2/library/user_transaction.dwt
./themes/default-ppg2/library/index.dwt
./themes/default-ppg2/library/user_passport.dwt
./themes/default-ppg2/library/goods.dwt
./themes/default-ppg2/article3.dwt
./themes/default-ppg2/index.dwt
./themes/default-ppg2/article5.dwt
./themes/default-ppg2/flow.dwt
./themes/default-ppg2/article1.dwt
./themes/default-ppg2/article4.dwt
./themes/default-ppg2/article.dwt
./themes/default-ppg2/message.dwt
./themes/default-ppg2/article2.dwt
./themes/default-ppg2/category.dwt
./themes/default-ppg2/user_passport.dwt
./themes/default-ppg2/search.dwt
./themes/default-ppg2/goods.dwt
find -name "*.php" -exec grep -n -H Louis/Site.css {} \;
find -name "*.dwt" -exec grep -n -H Louis/Site.css {} \;
3.       执行替换脚本
./replace.sh  "Louis\/Site.css"  "Louis\/test.css"
查找符合条件的文件名:find -name "*.dwt" -exec  awk '/Louis\/Site.css/{print FILENAME}' {} \;


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/100752/showart_1995884.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP