Bash arithmetic expression error -
count=0 grep $event $1 | while read line num="$(echo $line | cut -d " " -f 2)" count = $(( $count + $num )) done echo $count
so here code. i'm getting arithmetic expression error @ "count = $(( $count + $num ))". whats wrong that?
firstly, when start script error told me grep incorrect. indeed should define default value of $1 or require user.
next when typed script parameter 8, executed without end.
finally focused on arithmetic operator , wrote script:
a=3; b=4; x=$((a+b)); echo $x;
please test it. in code there unnecessary spaces.
note that
x = $((a+b));
will not work correctly.
Comments
Post a Comment