title: How to assign shell command output to a variable in C language
body: <p>I want the output of the shell command (<code>echo free | grep Mem| awk '{print $2}'</code>) collected in a variable so that I can use it in a C program. So I have the code here.</p>
  
  <pre><code> system("TOTAL=$(echo `free | grep Mem| awk '{print $2}'`)");
   popen("grep -v procs $1 | grep -v free | awk '{USED=TOTAL-$4-$5-$6;print USED}'", "r");
  </code></pre>
  
  <p>Can I use the variable TOTAL in the same program inside a popen() call as shown above ?</p>