title: How to convert string to number in bash
body: <p>So I have a file that has two lines in it. Both lines contain a number.
  I want to check if that number is a 0 or not and then echo it out if it is.
  However bash doesn't let me use the &quot;-eq&quot; operator and tells me the &quot;integer expression expected&quot; error.</p>
  <p>I have tried using an array and then a for loop and if statement to loop through the values but it didnt work.</p>
  <p>I have also tried using a while loop and loop through the lines in the file but got the same error.</p>
  <p>Using string comparisons doesn't seem to work as it doesn't recognise the 0. So I would like to convert the strings to numbers if possible.
  Can someone advise please.</p>
  <p><code>for i in `cat num.out`;do if [ &quot;$i&quot; -eq 0 ];then echo $i;fi;done</code></p>
  <p>The file num.out contains two lines:</p>
  <pre><code>cat num.out
  0
  0
  </code></pre>
  <p>The file num.out was compiled using the parsed output of another internal company script</p>
  <p>Per request:</p>
  <pre><code>cat -v num.out
  ^[[31m^[[1m0^[[0m
  ^[[31m^[[1m0^[[0m
  
  hexdump -C num.out
  00000000  1b 5b 33 31 6d 1b 5b 31  6d 30 1b 5b 30 6d 0a 1b  |.[31m.[1m0.[0m..|
  00000010  5b 33 31 6d 1b 5b 31 6d  30 1b 5b 30 6d 0a        |[31m.[1m0.[0m.|
  0000001e```
  </code></pre>