Reputation: 9793
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?
Upvotes: 11
Views: 24495
Reputation: 31548
In case you want be safe , you can escape the :
colon
sed -re "s/a\:b/b\:c/g" temp.txt
Upvotes: 9
Reputation: 4148
This worked for me:
-->cat 1
a:bLINE1
a:bLINE2
-->cat 1 | sed 's/a:b/b:c/g'
b:cLINE1
b:cLINE2
Upvotes: 5