I am having one file which contains some stuff. I want to use first column of the file and than make an array of that column. Now when i use grep in PHP to find the associated row from main file as per made array value the script just hangs produce no output. Below is my code-:
<?php
$temp=exec("wc -l /root/live/lastDateTemplate-28-11-2013.csv");
$removeHeading=$temp -1;
$getNewsletterNameFile=exec("awk 'BEGIN { FS = \",\" } ; { print $1 }' /root/live/lastDateTemplate-28-11-2013.csv | tail -$removeHeading > /root/live/demoFile.txt");
$fp=fopen('/root/live/demoFile.txt', 'r');
while (!feof($fp))
{
$getNewsletter=fgets($fp);
$getNewsletter=trim($getNewsletter);
$newsLetterName[]=$getNewsletter;
}
fclose($fp);
$lenOfNewsletterFile=count($newsLetterName);
$requiredLength=$lenOfNewsletterFile - 1;
$current_day_csvFile ="/root/live/lastDateTemplate-28-11-2013.csv";
for($i=0;$i<=$requiredLength;$i++)
{
$getRow=exec("grep ".$newsLetterName[$i]." ".$current_day_csvFile);
}
?>
awk. You are mixing many tools while not using one of them in the correct way.. that's why -1