syntax error near unexpected token `<<<'
<p>I have a bash script, which runs correctly in my system:</p>
<pre><code>uname -a
Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 GNU/Linux
</code></pre>
<p>But I need it to work in a Redhat 7.2 chroot:</p>
<pre><code>Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 unknown
</code></pre>
<p>The same code executes correctly on the first one, but when running it on 7.2 first it doesn't recognize sed -i (just the -i argument). Commenting some lines y run into another problem:</p>
<pre><code>bash: command substitution: line 1: syntax error near unexpected token `&lt;&lt;&lt;'
</code></pre>
<p>The thing is, that this script need to be executed in a remote machine with a debian 7.2 (that's why i'm testing it in a chroot with the same distro), so it's no solution to install modules/upgrades to make it runnable.</p>
<p>A sample code:</p>
<pre><code>#!/bin/bash       
...
count=0                                                                                                                                     
while read line; do                                                                                                                         
    if echo &quot;$line&quot; | grep -q ')'                                                                                                           
    then                                                                                                                                    
        ((count++))                                                                                                                         
        comas=`grep -o &quot;,&quot; &lt;&lt;&lt; &quot;$line&quot; | wc -l`                                                                                             
        num=`grep -o &quot;byRef&quot; &lt;&lt;&lt; &quot;$line&quot; | wc -l`  
...
sed -i 's/shortInteger/int/g' &quot;test.h&quot;
</code></pre>
<p>Any ideas?</p>
<p>Thanks.</p>
<p>Edit:
These are the commands that cause me trouble:</p>
<blockquote>
<p>comas=`grep -o &quot;,&quot; &lt;&lt;&lt; &quot;$line&quot; | wc -l`</p>
<p>sed -i 's/shortInteger/int/g' &quot;test.h&quot;</p>
</blockquote>
<p>Edit 2:</p>
<blockquote>
<p>GNU bash, version 2.05.8 --&gt; &quot;here string&quot; (&lt;&lt;&lt;) doesn't exist</p>
<p>grep (GNU grep) 2.4.2 --&gt; -o option doesn't exist</p>
<p>GNU sed version 3.02 --&gt; -i option doesn't exist</p>
</blockquote>