title: Redirect stdout over ssh
body: <p>I want to redirect the output of a sed command into a .txt file ( in the remote server), the code is as follows:</p>
  
  <pre><code>ssh -p XXYY -l root $remoteIP | sed '/keyword/d' /etc/fileA &gt; /etc/fileA_temp
  </code></pre>
  
  <p>I want to update a txt file deleting all the lines that contains a specific keyword and save it in the same file or somewhere where I could after copy it</p>
  
  <p>The first part of the code reply as wanted: </p>
  
  <pre><code>ssh -p XXYY -l root $remoteIP | sed '/keyword/d' /etc/fileA 
  </code></pre>
  
  <p>But the output in the line command says that <strong>'permission denied'</strong> to the 'fileA_temp' file and shows all the info about the options for ssh...Because of that I think that 'ssh' is not allowing to update the file in some way.</p>
  
  <p>EDIT: Inside the remote server, it works when I tried:</p>
  
  <pre><code>sed '/keyword/d' /etc/fileA &gt; /etc/fileA_temp
  </code></pre>
  
  <p>But the console said <strong>'permission denied'</strong> when I run it in a bash script.</p>
  
  <p>Thanks so much</p>