First things first, here's the code:
# build.prop Tweaks
FILE=/system/build.prop
#Properties to change Array
PROPARR=('net.tcp.buffersize.default' 'net.tcp.buffersize.wifi' 'net.tcp.buffersize.umts' 'net.tcp.buffersize.gprs' 'net.tcp.buffersize.edge' 'wifi.supplicant_scan_interval' 'ro.HOME_APP_ADJ' 'dalvik.vm.dexopt-flags' 'dalvik.vm.execution-mode' 'dalvik.vm.heapstartsize' 'dalvik.vm.heapgrowthlimit' 'dalvik.vm.heapsize' 'dalvik.vm.heaptargetutilization' 'dalvik.vm.heapminfree' 'dalvik.vm.heapmaxfree' 'debug.sf.hw');
#Property Values
PROPVALARR=('4096,87380,256960,4096,16384,256960' '4096,87380,256960,4096,16384,256960' '4096,87380,256960,4096,16384,256960' '4096,87380,256960,4096,16384,256960' '4096,87380,256960,4096,16384,256960' '300' '1' 'm=y,v=n,o=v,u=n' 'init:jit' '16m' '128m' '512m' '0.75' '12m' '16m' '1');
# this variable is just a place holder for the future line number of the prop values
lineNum=
# Loop through the properties I want to change
for i in $PROPARR; do
prop=$PROPARR($i);
arg=$PROPVALARR($i);
if grep -Fq $prop $FILE ; then
lineNum=`sed -n "/${prop}/=" $FILE`;
sed -i "${lineNum} c${prop}=${arg}" $FILE;
else
echo $prop=$arg >> $FILE;
fi;
done;
Now, orignally in the loop I was accessing the array like this: prop=$PROPARR[$i];
arg=$PROPVALARR[$i];
but it was writing weird code to the end of build.prop, and it was only the 1st item in the array(s)
So, then I tried it like I posted, and now I am getting a syntax error near unexpected token '('
So with the first issue that I was having, I feel it is safe to assume that #1 the loop isn't correctly written, #2 the text I am attempting to write is incorrectly written, #3 is the proper way to access the items
So the question is, how can I fix this so the loop loops correctly through the array, and writes the proper lines to build.prop (or updates the line if found)
array=(hello world)and 1. print the second element, 2. loop over and print each element. When you're not familiar with a language, it really helps to start small and fixing one error at a time rather than writing a complete program and then trying to fix everything at once.