Linux查找文件并使用sed正则替换内容 Bertha 。 2022-02-09 11:07 326阅读 0赞 原文件 test.js,内容如下: module.exports = { serve: 'https://demo.def.com:5004', keys: ['some secret hurr'], session: { key: 'koa:sess' } } 要求替换其中serve后面的值,使用如下命令: # 先定义变量 serve='http://test.domain.com:8888' # 然后使用命令替换 find ./ -name *.js|xargs sed -i "s#serve[^,]*#serve: \'$serve\'#g" (END)
还没有评论,来说两句吧...