Use sed to replace all backslashes with forward slashes

后端 未结 9 848
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 04:09

I want to be able to use sed to take an input such as:

C:\\Windows\\Folder\\File.txt

to

C:/Windows/Folder/File.txt
<         


        
相关标签:
9条回答
  • 2020-11-27 04:54

    Just use:

    sed 's.\\./.g'
    

    There's no reason to use / as the separator in sed. But if you really wanted to:

    sed 's/\\/\//g'
    
    0 讨论(0)
  • 2020-11-27 04:55

    This might work for you:

    sed 'y/\\/\//'
    
    0 讨论(0)
  • 2020-11-27 04:55

    For me, this replaces one backslash with a forward slash.

    sed -e "s/\\\\/\//"  file.txt
    
    0 讨论(0)
提交回复
热议问题