title: using exec to sort a text file in c
body: <p>I have a text file full of records (output.txt) and I want to sort every record by its id. After the sorting the sorted records are written into a new file (sorted.txt).</p>
  
  <p>To do that I am using bash's command "sort" via an execl() function. To check the validity of my sort command, I wrote the same command straight into the bash and the result is the expected one. But when I try to use the execl command through my C program, most of the time the answer will be that there is not a file /usr/bin/sort (I am using Mac OSX) or no error message will be thrown but nevertheless nothing happens...
  What I am using is this:</p>
  
  <pre><code>execl("/usr/bin/sort", "usr/bin/sort", "-n","-k", "1", "-u", "output.txt", "&gt;", "sorted.txt", (char*)NULL);
  </code></pre>
  
  <p>or this</p>
  
  <pre><code>execl("/usr/bin/sort", "usr/bin/sort", "-n","-k", "1", "-u", "-o", "sorted.txt", "output.txt", (char*)NULL);
  </code></pre>
  
  <p>I know that both of these 2 sort commands are correct when I m using them in the bash. What happens to C?
  Thnx all in advance!</p>