How to use Sed to replace all characters in between colons

lim0721lim

How to replace all characters between colons using 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
cuonglm

Try:

$ sed -e 's/:[^:]*:/:123:/' file
sed:123:abc
sed:123:efg
sed:123:zyx

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to find and replace between characters

Replace all characters between Regular expression

How to use gnu sed to replace all but one word?

How to replace specific characters with tab using sed

Extract substring between two colons / special characters

How to use regex in Swift to capture string between colons

How to replace all given characters?

Use sed to replace multiple special characters

How to recursively replace characters with sed?

Sed replace all characters until first space

how to use sed to replace from last 3 characters from string

Using sed to replace characters between two patterns

How to use sed to replace & with &

Replace All Colons From Filenames With Terminal

Replace specials characters with sed

How to use sed to replace a whole line with another one with characters in it

How to remove everything between two characters with sed?

Use sed or awk to replace text between column

How to remove everything between two characters with SED?

Using sed to replace single quotes between two characters

how to replace all characters of a header

sed/awk/python replace all spaces between characters after string match

How can I use sed to replace multiple characters?

Bash sed: Replace all special characters (Invalid range end)

How to replace a string of specific characters with sed command

How to replace quotation marks with angle brackets between two patterns recursively for all file in a directory with sed?

How to use sed or another command line function to remove . between characters

How to find and replace text with sed but with special characters

Replace all spaces between certain characters with regex