In a text file I need to remove non-escaped characters like in the following example
"\\s" -> "\s"
"\s" -> ""
I need to use sed for this excercise. I made this command:
s/\([^\]\)\\s/\1/g
s/\\\\/\\/g
The problem I now encounter is the fact that \s at the beginning of a line is not beïng removed. What sould be added to the regex to acomplish this. I also tried the * and ? but the problem with these is that they also remove the \\s strings.
So I really need a way to match ‘not a backslash or a line start’.
This might work for you:
a three step process:
\sto\n\\nto\s\n‘s i.e. the original\s‘sN.B. I use
\nbecause it cannot appear in the original line as sed uses it as a line delimiter.