I am trying to replace _ with : in a file on a Unix system using sed:
sed "s/'_''/:/g"
However, it doesn't work. I cannot find a solution in similar sed related posts.
I am trying to replace _ with : in a file on a Unix system using sed:
sed "s/'_''/:/g"
However, it doesn't work. I cannot find a solution in similar sed related posts.
You have an extra single quote, and, in fact, don't need the quotes at all. The underscore and the colon are not significant to the shell. You are asking sed to match '_'' (all four characters) and replace them with a colon.
$ echo "_This is a test_" | sed s/_/:/g
:This is a test:
Not that quotes aren't a good idea...