linux改变文件内容,linux批量修改文件内容

脚本目的:把一个目录下所有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" -execawk '/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" -execawk '/Louis\/Site.css/{print FILENAME}' {} \;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值