title: Getting "numeric argument required" when running a script with arithmetic operations
body: <p>I'm trying to write a function that is supposed to convert a time stamp of the form hr:min:sec,ms (i.e 15:41:47,757) to milliseconds. The function is the following:</p>
  <pre><code>#!/bin/sh
  mili () {
  
      hr=$(echo &quot;$1&quot; | cut -c1-2)
      echo &quot;hr is: &quot; $hr
      min=$(echo &quot;$1&quot; | cut -c4-5)
      echo &quot;min is: &quot; $min
      sec=$(echo &quot;$1&quot; | cut -c7-8)
      echo &quot;sec is: &quot; $sec
      ms=$(echo &quot;$1&quot; | cut -c10-12)
      echo &quot;ms is: &quot; $ms
      total=$(($hr \* 3600 + $min \* 60 + $sec) \* 1000 + $ms)
  
      return &quot;$total&quot;
      #echo &quot;Result is: &quot;$total&quot; &quot;
  }
  
  mili $1
  </code></pre>
  <p>However, when I run it:</p>
  <pre class="lang-none prettyprint-override"><code>./mili.sh &quot;15:41:47,757&quot;
  </code></pre>
  <p>I get the following output message:</p>
  <pre class="lang-none prettyprint-override"><code>./mili.sh: command substitution: line 15: syntax error near unexpected token 
  `\*'
  ./mili.sh: command substitution: line 15: `($hr \* 3600 + $min \* 60 + $sec) 
  \* 1000 + $ms'
  ./mili.sh: line 17: return: : numeric argument required
  </code></pre>
  <p>I've tried variations of expr with and without single quotes, double quotes, and backticks but can never seem to get it to compute the arithmetic. I can confirm a simple command like this works:  expr 2 * 3 but when I try to use something similar in my script it fails.</p>
  <p>How can I get it to simply compute my expression?</p>