title: redirecting output to a file in C
body: <p>i coded a basic shell in C for executing basic commands it'll execute commands <code>ls</code>, <code>ls -al</code> , <code>ls -al | more</code> etc.</p>
  
  <p>i want to execute following command in my shell.
  like ;</p>
  
  <pre><code>ls -al &gt; a.txt
  </code></pre>
  
  <p>this will give me <code>a.txt</code> file which contain output of <code>ls -al</code> process.
  i found a one solution, it's changing the command in my shell like <code>[command1] | tee [filename]</code>. in this instance it'll change <code>ls -al &gt; a.txt</code> to <code>ls -al | tee a.txt</code>. but this process gives the output to file and terminal as well. how to stop printing output in terminal.</p>
  
  <p>or are there are any better solution rather than using tee command.
  thanks in advance...</p>