Why do we care about the escaping backslash in JSON? Sed does provide a few extra options when specifying regular expressions. Explanation: Sometimes it's really tricky and ugly (the output) to manually escape a character sequences in allready escaped stuff in database. Because when you’re writing a JSON string, if there’s a backslash in the string, you have to escape it by prefixing with another backslash. To use a comma instead of a slash, use: sed '\,^#, s/[0-9][0-9]*//' The main advantage of this feature is searching for slashes. For instance, to do this replacement correctly I should escape the second path: For example, the following sed command emphasizes every word: In this particular case, the Apache configuration file has lines with #’s not at the beginning of some lines, ... Another use of sed consists in printing the lines from a file that match a given regular expression. \" A literal double quote (should be used for string constants only). And that is something very useful! If you want the replace some occurences of a URL in a file the sed command looks really ugly because you have to escape every slash "/" with a backslash "\" To make it look a lot cleaner you could just change the delimiter used by sed: Because the regexp is delimited by slashes, you need to escape any slash that is part of the pattern, in order to tell awk to keep processing the rest of the regexp. Below is the init container I am using, I need to use sed to modify on the fly one parameter, when I run kubectl create -f container.yaml I see this error: kubectl create -f tgtd-pod-v2.yaml unable to decode "tgtd-pod-v2.yaml": invalid character '(' in string escape code. But I'll discuss those later. If you want to edit the file, add -i: sed -i 's/ / \\ /' hw The command replaces the space by space\space. means return \t. Though you still need to escape the '\' to stop sed misinterpreting it, you won't need to escape … You need two \\ because \ is an escape character. If you have a file named hw containing Hello World, the sed command would be: sed 's/ / \\ /' hw This displays the wanted result on the screen. Regular-expression matches Example echo -e 'find fend found' | sed 's/f.nd/replace/g' Output replace replace found Explanation. I was editing a file and found accidentally that I somehow escaped all the forward slashes in a path I was replacing in text. In computer programming, leaning toothpick syndrome (LTS) is the situation in which a quoted expression becomes unreadable because it contains a large number of escape characters, usually backslashes ("\"), to avoid delimiter collision.. sed can also use a regular expression to find matches. If you need to use sed because you're doing something more complex than that, then a little known tip is that you can actually use other delimiters to make it more readable. means newline \r. Properly escaping forward slash in bash script for usage with sed Helpful? Linux Bash->SED compatible online escape character tool v.1.3. The same command run in shell works without any errors. The vertical bars indicate boolean operations, whereas the backward slash is used to escape the vertical bars. Put into Input Box the character sequence you want to escape: Input: Output: ESCPAE. With certain commands and utilities, such as echo and sed, escaping a character may have the opposite effect - it can toggle on a special meaning for that character. used with echo and sed \n. If the expression starts with a backslash, the next character is the delimiter. Special meanings of certain escaped characters. As we see, we can use \ to escape / to include a / when / is the delimiter. …