title: Bash function give as parameter -> ssh archive remote folder in local archive.tar.gz -> echo "test" also packed in tar file
body: <p>Hi I have a bash function:</p>
  
  <pre><code>function echoAndExecArgs 
  {
  
  echo -e "\n\n======== command: $@  ========"
  $@
  
  }
  </code></pre>
  
  <p>It echoes the command and all its parameters to stdout and executes it.</p>
  
  <p>Now I give the following command:</p>
  
  <pre><code>ssh root@remoteMachine tar -czvf- /someFolder 2&gt;&gt; sterr.log | dd of=archive.tar.gz
  </code></pre>
  
  <p>The problem ist that the string <code>"\n\n======== command: $@  ========"</code> gets also written into the beginning of my <code>archive.tar.gz</code> file.</p>
  
  <p>If I do <code>xxd -l 100 archive.tar.gz</code> I see that the string <code>"\n\n======== command: $@  ========"</code> is written at the beginning of the file. This of course leads to the problem that the file is corrupted and cannot be extracted as usual.</p>
  
  <p>My question is: How is it possible to give my ssh command as parameter to the function <code>echoAndExecArgs</code> that it only redirects the actual file output of the tar command into the file <code>archive.tar.gz</code> and not all std outputs of the whole function?</p>
  
  <p>This approach gives the same wrong result:</p>
  
  <pre><code>ssh user@host "tar -zcf - /someFolder" &gt; archive.gz
  </code></pre>