【问题标题】:Shell Find and Replace Domain in all files and its folder, sub folderShell 在所有文件及其文件夹、子文件夹中查找和替换域
【发布时间】:2014-08-04 04:25:31
【问题描述】:

我有一个域

https://account.oldomain.com

我现在迁移到一个新域

https://account.newdomain.com

我想用 account.newdomain.com 替换所有出现的 account.olddomain.com

我该怎么做

我知道我可以使用类似的东西

sed -i 's/account.oldomain.com/account.newdomain.com/g' /hello

但是 sed: 无法编辑 /hello: 不是常规文件

如何替换当前目录中的所有文件,以及它的目录,目录的子目录,就像在当前文件夹的所有文件和文件夹中一样

with containing the text account.oldomain.com with account.newdomain.com

谢谢!!

【问题讨论】:

    标签: regex linux sed


    【解决方案1】:

    尝试:

    find /hello -type f|xargs sed -i 's#\(account[.]\)oldomain\([.]com\)#\1newdomain\2#g' 
    

    我更改了您的 . -> [.],以完全匹配 dot,而不是任何字符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-29
      • 1970-01-01
      • 2017-04-20
      • 1970-01-01
      • 2015-02-16
      • 1970-01-01
      • 2019-06-19
      • 1970-01-01
      相关资源
      最近更新 更多