title: shell-scripting: Use a pipe as an input for tar
body: <p>I'm trying to figure out a way to use tar+pipes on a Ubuntu Server LTS.</p>
  
  <p>I've got a postgresql command (<code>pg_dump</code>) that outputs lots of sql on the standard output:</p>
  
  <pre><code>pg_dump -U myUser myDB
  </code></pre>
  
  <p>I know how to redirect that to a file:</p>
  
  <pre><code>pg_dump -U myUser myDB &gt; myDB.sql
  </code></pre>
  
  <p>In order to save some disk space, I would rather have it compressed: I can do a tar.gz file from that myDB.sql, and then delete myDB.sql.</p>
  
  <p>But I was wondering - is there a way of doing this without creating the intermediate .sql  file? I believe this could be accomplished with pipes... however I'm no shell guru, and know very little about them (I'm able to do <code>ls | more</code>, that's all). I've tried several variations of <code>pg_dump .. | tar ...</code> but with no success.</p>
  
  <p>How can I use a pipe to use the output of <code>pg_dump</code> as an input for tar? Or did I just get something wrong?</p>