Sed を使用してコロンの間のすべての文字を置換する方法

Sed を使用してコロンの間のすべての文字を置換する方法

コロンの間のすべての文字を ? を使用して置き換えるにはどうすればよいでしょうか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

関連情報