Originally Posted by inameiname
Thanks for the suggestion, unfortunately it doesn't work either.
I didn't try "sed -i -e 's/.../'" yet. What would that do, and how would I write it in this case?
It's actually just the long form of your command, i.e. explicitly saying "the s/.../ part is the expression to be evaluated". try sed --help on your device, you'll find the info there. I actually wasn't even aware that one could omit the "-e".
Anyway, I just ran this on the device, and sed is working as it should.
[root@kindle tmp]# echo 12345600789 > test.txt
[root@kindle tmp]# sed -e 's/600/900/' test.txt
I looked at your code again, and there is something fishy: if the backup file doesn't exist, it is created from the current configuration. It doesn't necessarily contain "600", though. So maybe this is why it's failing.
I would suggest to rewrite the thing to a simpler and "less dangerous" variant, something like:
if [ -f /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout.TEMPLATE ]
sed -e 's/_TIMEOUT_/900/' /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout.TEMPLATE > /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout
You would create the TEMPLATE file exactly once (maybe on installation, whatever), and instead of putting some exact number in there, put _TIMEOUT_ in the respective place. This is the pattern that'll be replaced. I also suggest not to duplicate the logic over 5 files, but create it once, and parameterize it... Along the lines of "set_timeout.sh 900". Instead of hard-coding the value, you'd just use $1 in the script.