Failed to replace string with "sed"

Hi folks,

I have the following configuration file:

tofu:/tmp # cat bitbandConfig.properties 
maestroIp=10.10.10.10
maestroPort=2020
adminPlayPath=<Streaming Agent IP>:2021/streamingGateway/GetPlayList

###This part should not be changed###

adminPlayVODProtocol=http

username=iptv
password=iptv
soapContext=bitband/services/IPTVPlugin

adminFileFormat=.asx

mediaFilePath=
playerJSPath=bitbandPlayer.js

serviceUnitId=1$-$VOD#0$-$VOD

### vs agnostic properties ###
encodingFormats=MPEG-1$-$MPEG_1_SYSTEM#MPEG-2$-$MPEG_2_TRANSPORT#MPEG-4$-$MPEG_4

I'm trying to replace in its last line the string :#MPEG-4$-$MPEG_4 with #MPEG-4$-$MPEG4_H264

I ran a simple sed command:

sed 's/#MPEG-4\$-\$MPEG_4/#MPEG-4\$-\$MPEG4_H264/g' bitbandConfig.properties

I got 2 problems:

  1. The strings were not substituted.
  2. The last line was deleted!

What did I do wrong?

Thanks in advance,
Nir

I'll simplify my question:
How can I substitute the string "#MPEG-4$-$MPEG_4" with the string "#MPEG-4$-$MPEG4_H264"?

I tried this :

tofu:/tmp # echo "#MPEG-4\$-\$MPEG_4" | sed -e 's/"MPEG-4\$-\$MPEG_4"/"MPEG-4\$-\$MPEG4_H264"/'

#MPEG-4$-$MPEG_4

As you can see,I didn't succeed :confused:

Thanks in advance,
Nir

remove the double quotes from your sed command

echo "#MPEG-4\$-\$MPEG_4" | sed -e 's/MPEG-4\$-\$MPEG_4/MPEG-4\$-\$MPEG4_H264/'

Hi sssow,

Thanks!
In the echo command it works fine but when I'm running this command on the file ,the last line which contains the strings is deleted!

Before sed:

tofu:/tmp # cat bitbandConfig.properties 
maestroIp=10.10.10.10
maestroPort=2020
adminPlayPath=<Streaming Agent IP>:2021/streamingGateway/GetPlayList

###This part should not be changed###

adminPlayVODProtocol=http

username=iptv
password=iptv
soapContext=bitband/services/IPTVPlugin

adminFileFormat=.asx

mediaFilePath=
playerJSPath=bitbandPlayer.js

serviceUnitId=1$-$VOD#0$-$VOD

### vs agnostic properties ###
encodingFormats=MPEG-1$-$MPEG_1_SYSTEM#MPEG-2$-$MPEG_2_TRANSPORT#MPEG-4$-$MPEG_4

After sed:

tofu:/tmp # sed -e 's/MPEG-4\$-\$MPEG_4/MPEG-4\$-\$MPEG4_H264/' bitbandConfig.properties
maestroIp=10.10.10.10
maestroPort=2020
adminPlayPath=<Streaming Agent IP>:2021/streamingGateway/GetPlayList

###This part should not be changed###

adminPlayVODProtocol=http

username=iptv
password=iptv
soapContext=bitband/services/IPTVPlugin

adminFileFormat=.asx

mediaFilePath=
playerJSPath=bitbandPlayer.js

serviceUnitId=1$-$VOD#0$-$VOD

### vs agnostic properties ###

Why?

Thanks in advance,
Nir

Your sed command seems to work fine.

[/tmp]$ tail -1 < try
encodingFormats=MPEG-1$-$MPEG_1_SYSTEM#MPEG-2$-$MPEG_2_TRANSPORT#MPEG-4$-$MPEG_4
[/tmp]$ sed 's/#MPEG-4\$-\$MPEG_4/#MPEG-4\$-\$MPEG4_H264/g' try | tail -1
encodingFormats=MPEG-1$-$MPEG_1_SYSTEM#MPEG-2$-$MPEG_2_TRANSPORT#MPEG-4$-$MPEG4_H264

Something to do with your sed ?? :confused:

Hey vino my friend!
Thanks a lot!

It also works now on the file:

tofu:/tmp # sed 's/#MPEG-4\$-\$MPEG_4/#MPEG-4\$-\$MPEG4_H264/g' bitbandConfig.properties
maestroIp=10.10.10.10
maestroPort=2020
adminPlayPath=<Streaming Agent IP>:2021/streamingGateway/GetPlayList

###This part should not be changed###

adminPlayVODProtocol=http

username=iptv
password=iptv
soapContext=bitband/services/IPTVPlugin

adminFileFormat=.asx

mediaFilePath=
playerJSPath=bitbandPlayer.js

serviceUnitId=1$-$VOD#0$-$VOD

### vs agnostic properties ###
encodingFormats=MPEG-1$-$MPEG_1_SYSTEM#MPEG-2$-$MPEG_2_TRANSPORT#MPEG-4$-$MPEG4_H264

Did you change something in my sed command or your magic hands did the job?

Best regards,
Nir

I did not change anything. Your sed statement worked just fine.

Cheers' !

Cool!
Thanks pal.