Skip to main content

forHow to replace values in a string using sed but keep the string intact?

For example echo "01XX1234" imecho "01XX1234"

I'm looking to replace XX WithXX with a hex value and leave the 0101 and the 1234 in tact, ive1234 intact. I've tried every combination iI can think of but sedsed is getting the better of me.

iI can do it like this but is theirthere an easier way echo "01XX1234" | sed -n 's/(01..1234)/01AB1234/g'?

echo "01XX1234" | sed -n 's/\(01..1234\)/01AB1234/g'

for example echo "01XX1234" im looking to replace XX With hex value and leave the 01 and the 1234 in tact, ive tried every combination i can think of but sed is getting the better of me

i can do it like this but is their an easier way echo "01XX1234" | sed -n 's/(01..1234)/01AB1234/g'

How to replace values in a string using sed but keep the string intact?

For example echo "01XX1234"

I'm looking to replace XX with a hex value and leave the 01 and the 1234 intact. I've tried every combination I can think of but sed is getting the better of me.

I can do it like this but is there an easier way?

echo "01XX1234" | sed -n 's/\(01..1234\)/01AB1234/g'
Source Link

How to replace values in a string using sed but keep the string intact

for example echo "01XX1234" im looking to replace XX With hex value and leave the 01 and the 1234 in tact, ive tried every combination i can think of but sed is getting the better of me

i can do it like this but is their an easier way echo "01XX1234" | sed -n 's/(01..1234)/01AB1234/g'