【问题标题】:replace string with spaces in origin string用原始字符串中的空格替换字符串
【发布时间】:2018-12-01 21:13:37
【问题描述】:

我正在尝试将 \\server\share\doc share\PDF 之类的字符串替换为 \\server2\share\client\01-client-doc\00-verified\PDF 之类的字符串。

第一步我只播放一个文件,然后我将更改所有其他文件。

这是我正在使用的确切命令。

sed -i -e 's/server\share\doc share\PDF/server2\share\client\01-client-doc\00-verified\PDF/g' file.txt

【问题讨论】:

  • 使用# 代替/

标签: string sed replace space


【解决方案1】:

另一方面,您需要保护您的 \ \s 表示 whitespaces(制表符、换行符、垂直制表符、换页、回车和空格)

sed -i -e 's/server\\share\\doc share\\PDF/server2\\share\\client\\01-client-doc\\00-verified\\PDF/g' file.txt

【讨论】:

    猜你喜欢
    • 2016-03-01
    • 1970-01-01
    • 2013-05-09
    • 2020-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-04
    • 1970-01-01
    相关资源
    最近更新 更多