如何使用 替换冒号之间的所有字符sed
?
# replace easy with 123
sed:easy:abc -> sed:123:abc
# replace hardest with 123
sed:hardest:efg -> sed:123:efg
# replace magnificent with zyx
sed:magnificent:zyx -> sed:123:zyx
答案1
尝试:
$ sed -e 's/:[^:]*:/:123:/' file
sed:123:abc
sed:123:efg
sed:123:zyx