Reputation: 653
I am trying to pass back the results/variables from the awk command (called from PHP) back to the PHP script for further manipulation. Following is my script:
$cmd = "/usr/bin/awk '{if($1 >= \"$S_Date\" && $1 <= \"$E_Date\"){sum+=$5; row+=1}} END{avg=sum/row;print avg}' data.txt";
$avg = system($cmd);
echo "Avg: $avg\n";
where, $S_Date
and $E_Date
are PHP variables. I can get the avg from awk returned in the $avg
var but, have the following issues.
Issues:
Thanks.
Upvotes: 1
Views: 755