title: Scanning the output of a program at shell
body: <p>Hello I am currently trying to make a script file in Linux that has as input the output of o prgram and scans it to find how many occurences of some words are existed. To be clearer I want to scan the output and store to variables how many times some words exist in that output. I am new to scripitin in linux. I tried storing the output in a file and then scan it line by line in order to find the words but for somre reason the loop i use to parse it never ends. Can you help me?</p>
  
  <pre><code>./program &gt; buffer.txt
  
  while read LINE
  do
  echo $LINE | grep word1  #when i use grep command the loop never ends
  done &lt;a.txt
  </code></pre>
  
  <p>Edit: In C an equivalent program would be</p>
  
  <pre><code>char* word="word1"
  while(/*parse all the lines at a text */)
  {
  fgetline("file_a",&amp;buffer)
  if(strcmp(buffer,word)==0)
   strcpy(word1,"word") //continue the search with this 
  }
  </code></pre>