Ahmad Fikri Ahmad Fikri - 2 months ago 6x
Bash Question

How to use 2 sed commands in a single file as a input value?

I have 2

command in one sh file to input value for other sh file like this

sed -i '23 i\if [ $REPLY == '0,5120,10240,20480,40960,65536' ]; then' /system/0211/0211tr.sh
sed -i '27 i\elif [ $REPLY == '6144,12288,18432,32768,49152,57344' ]; then' /system/0211/0211tr.sh

is working, but another one is not. First
, insert a value in line 23, and second
insert value in line 27. There is another way to make this work? I run this in Android device

sps sps

You can change your quotes from single quotes ' to souble quotes " for the sed command, as you have single quotes ' in the text you are inserting too.

Also once you change the quotes, you need to escape characters like $ and \ with a \.

And, you can have those two inserts into one single sed command.

sed -i -e "23 i\\if [ \$REPLY == '0,5120,10240,20480,40960,65536' ]; then"  \
       -e "27 i\\elif [ \$REPLY == '6144,12288,18432,32768,49152,57344' ]; then" \