【问题标题】:Replace backslash with slash using sed [duplicate]使用 sed 将反斜杠替换为斜杠 [重复]
【发布时间】:2018-05-07 18:36:12
【问题描述】:

我需要将\ 替换为/

我有一个文件:

test\test2\test3\test4

我试过了

VRS_Ruta=$(cat ruta.lst | sed 's/^.//g' | sed 's,/,///,g' )

输出

test\test2\test3\test4

我需要:

test/test2/test3/test4

【问题讨论】:

    标签: bash unix sed


    【解决方案1】:

    您可以使用以下内容:

     sed 's/\\/\//g'
    

    【讨论】:

    • 优秀的答案。略短的替代方案:sed 's|\\|/|g'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-27
    • 2011-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多