title: Redirect command output to file (existing command)
body: <p>To write the stdout of a command (in this case, <code>echo hi</code>) to a file, you can do:</p>
  
  <pre><code>echo hi &gt; outfile
  </code></pre>
  
  <p>I would like a command instead of a redirection or pipe so that I do not need to invoke a shell. This is eventually for use with Ansible, which calls python's <code>subprocess.POpen</code>.</p>
  
  <p>I am looking for:</p>
  
  <pre><code>stdout-to-file outfile echo hi
  </code></pre>
  
  <p><code>tee</code> makes copying stdout to a file easy enough, but it accepts stdin, not a separate command.</p>
  
  <p>Is there a common, portable command that does this? It's easy enough to write one, of course, but that's not the question. Ultimately, in Ansible, I want to do:</p>
  
  <pre><code>command: to-file /opt/binary_data base64 -d {{ base64_secret }}
  </code></pre>
  
  <p>Instead of:</p>
  
  <pre><code>shell: base64 -d {{ base64_secret }} &gt; /opt/binary_data
  </code></pre>
  
  <p>Edit: Looking for a command available on RHEL 7, Fedora 21</p>