I want to replace special character "/" with a special character "*" using sed command. EXAMPLE-
I / YOU.
I * YOU.
I want to replace special character "/" with a special character "*" using sed command. EXAMPLE-
I / YOU.
I * YOU.
As detailed in the comment Escaping forward slashes in sed command
You can use instead of
sed "s/target/replacement/" file
either
sed "s|target|replacement|" file
or
sed "s@target@replacement@" file
Command:
$ echo "I / YOU." | sed 's@/@*@'
I * YOU.
More generally when looking at the sed
accepted syntax:
[2addr] s/BRE/replacement/flags
Substitute the replacement string for instances of the BRE in the pattern space. Any character other than backslash or newline can be used instead of a slash to delimit the BRE and the replacement. Within the BRE and the replacement, the BRE delimiter itself can be used as a literal character if it is preceded by a backslash.
You can also go for another approach in which you do not change the separators but you use the hexadecimal value of the character you want to replace, this will also avoid ambiguity. (http://www.asciitable.com/)
$ echo "I / YOU." | sed 's/\x2F/*/'
I * YOU.