title: syntax error near unexpected token near `('
body: <p>Command below does not run from script:</p>
  <pre class="lang-sh prettyprint-override"><code>zcat *|cut -d&quot;,&quot; -f1,2 | tr -d &quot;\r&quot; |
  awk -F &quot;,&quot; '{if (\$1 ==&quot;\&quot;word\&quot;&quot; || \$1 ==&quot;\&quot;word2\&quot;&quot;){printf &quot;\n%s&quot;,\$0}else{printf &quot;%s&quot;,\$0}}' |
  grep -i &quot;resultCode&gt;00000&quot; | wc -l
  </code></pre>
  <p>Error:</p>
  <pre><code>./script.sh: command substitution: line 8: syntax error near unexpected token `('
  ./script.sh: command substitution: line 8: `ssh -t user@ip 'cd &quot;$(ls -td path/* | tail -n1)&quot; &amp;&amp; zcat *|cut -d&quot;,&quot; -f1,2 | tr -d &quot;\r&quot; | awk -F &quot;,&quot; '{if ($1 ==&quot;\&quot;word\&quot;&quot; || $1 ==&quot;\&quot;word2\&quot;&quot;){printf &quot;\n\%s&quot;,$0}else{printf &quot;\%s&quot;,$0}}'| grep -i &quot;resultCode&gt;00000&quot; | wc -l''
  </code></pre>
  <p>How should i fix syntax error near unexpected token?</p>