title: How to save output of SQL query fired from Osquery to a file
body: <p>I have installed Osquery utility on my machine. When I fire an SQL command, it gives output to STDOUT. Is there any way to redirect that output to a file?</p>
  
  <pre><code>$ sudo osqueryi 
  I0314 10:57:51.644351  3958 database.cpp:563] Checking database version for migration
  I0314 10:57:51.644912  3958 database.cpp:587] Performing migration: 0 -&gt; 1
  I0314 10:57:51.645279  3958 database.cpp:619] Migration 0 -&gt; 1 successfully completed!
  I0314 10:57:51.645627  3958 database.cpp:587] Performing migration: 1 -&gt; 2
  I0314 10:57:51.646088  3958 database.cpp:619] Migration 1 -&gt; 2 successfully completed!
  Using a virtual database. Need help, type '.help'
  osquery&gt; 
  osquery&gt; 
  osquery&gt; SELECT * from memory_info;
  +--------------+-------------+----------+----------+-------------+-----------+----------+------------+-----------+
  | memory_total | memory_free | buffers  | cached   | swap_cached | active    | inactive | swap_total | swap_free |
  +--------------+-------------+----------+----------+-------------+-----------+----------+------------+-----------+
  | 513617920    | 270921728   | 15110144 | 99860480 | 0           | 145080320 | 59494400 | 0          | 0         |
  +--------------+-------------+----------+----------+-------------+-----------+----------+------------+-----------+
  osquery&gt; 
  </code></pre>
  
  <p>I want this output in a file. I checked Osquery official documentation. But it hasn't been helpful to solve this particular problem.  <a href="https://osquery.readthedocs.io/en/stable/introduction/sql/#sql-as-understood-by-osquery" rel="nofollow noreferrer">https://osquery.readthedocs.io/en/stable/introduction/sql/#sql-as-understood-by-osquery</a></p>