-1

I am trying to replace '' with '\' character using sed command

echo "F:\RDAR\P003\P003\20220701" | sed 's/ \ / \\ /g'

I don't know what's wrong with this command

I expect this 'F:\\RDAR\\P003\\P003\\20220704'

1 Answers1

1

You need to escape the backslashes, so \ becomes \\:

sed 's,\\,\\\\,g'

or the slightly more hard to read for people with eyesight like my own:

sed 's/\\/\\\\/g'
Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108