Edit variable in a file

Hello,
I have a script which reads variable values from /system/pt.conf
I sourced it already.

But the probelm is I don't know how to edit only the value from the variable "res" in the conf file.

pt.conf:

res=1280x720
log=1

And I want to edit the value "1280x720" from "res".

I was trying

sed -i 's/$res/320x480/g' /system/pt.conf

But it didn't worked. Still the same value.

Hi, try:

'/^res=/s/=.*/=320x480/'

Thanks,
I tried it but I get a "blank" line.
I need to press Ctrl+C to get out of it.

Try this.

sed -i 's/res=1280x720/res=320x480/g' /system/pt.conf
$ cat set-res.sh
# usage set-res.sh 300x300
new_res="$1"
sed -i "s/^res=.*/res=$new_res/" /system/pt.conf
1 Like

Thank you,
that worked.