No output on bash program
<p>Currently working on a bash program to output a string of numbers based off the user input in the arg line command. </p>

<p>When I execute the program I receive the error </p>

<pre><code>line 3: [: missing `]'
</code></pre>

<p>Looking on line led me to believe the error was caused by incorrect syntax but I don't seem to see what that incorrect syntax is. Removing <code>&amp;&amp;$var &lt; 50</code> fixes the error but then the program proceeds to output nothing. </p>

<pre><code>#!/bin/bash
var=$1
if [ $var &gt; 1&amp;&amp;$var &lt; 50 ]; then
    if [ $var%2 ==  0 ]; then
    $var = $var/2
    echo $var ","
    elif [ $var%2 == 1 ]; then
    $var = 3 * $var + 1;
    echo $var ","
    fi
fi
</code></pre>

<p>Using shellscript to check the code I have edited it to:</p>

<pre><code>#!/bin/bash
var=$1
if [[ $var -gt 1 &amp;&amp; $var -lt 50 ]]; then
    if [ "$var%2" ==  0 ]; then
    var=$((var/2))
    echo "$var"
    elif [ "$var%2" == 1 ]; then
    var=$((3*var+1));
    echo "$var"
    fi
fi
</code></pre>

<p>I no longer receive the original error, however, the code goes through the loop once instead of re-iterating and updating the value of var each time.</p>

<p>Figured out the answer to that last question on my own and the code now compiles and run correctly. Thank you everyone who helped.</p>