title: MongoDB find() output to file
body: <p>Is there a way to write the output of a MongoDB find() query to a file just by simply using a Linux shell command or running a script?</p>
  
  <p>Right now I have to manually type in step-by-step. Example:</p>
  
  
  
  <pre class="lang-sh prettyprint-override"><code>$ mongo
  &gt; use owndb
  &gt; db.CollectionName.find(&lt;query&gt;) ### and then copy and paste the result on a text editor
  </code></pre>