sed - replacing text with colon
17,990
Solution 1
This worked for me:
-->cat 1
a:bLINE1
a:bLINE2
-->cat 1 | sed 's/a:b/b:c/g'
b:cLINE1
b:cLINE2
Solution 2
In case you want be safe , you can escape the :
colon
sed -re "s/a\:b/b\:c/g" temp.txt
Author by
user1508893
Updated on June 28, 2022Comments
-
user1508893 almost 2 years
I have this command:
sed -i "s/a:b/b:c/g" file.txt
(in English: replace "a:b" with "b:c" in file.txt)
This doesn't work because of the colons in the subsitution text. How should I re-write the command?
-
speakr over 11 years
-
user1508893 over 11 yearsYeayh, it does. It was not it. It failed due to something else, which I figured out.
-
A B over 11 yearsIt sounds like a good question - at least now I am sure the colon is not treated as a special character by sed!