How to write a shell script which accepts array in the command line and outputs the sum of it
<p>I am new to arrays in Bash scripting. I need to write a script which accepts an array from standard input on the command line. and outputs the sum of it to the user.</p>

<p>Here is the logic, but how can I convert it into shell script to be used in command line?</p>

<pre><code>read -a array

tot=0
for i in ${array[@]}; do
  let tot+=$i
done

echo "Total: $tot"
</code></pre>

<p>Any help is appreciated.</p>