title: How to redirect grep to a while loop
body: <p>Hi I have the following bash script code</p>
  
  <pre><code>group2=0
      while read -r line
      do
        popAll=$line | cut -d "{" -f2 | cut -d "}" -f1 | tr -cd "," | wc -c
          if [[ $popAll = 0 ]]; then
            group2 = $((group2+2)); 
          else
            group2 = $((group2+popAll+1));
          fi
      done &lt;&lt; (grep -w "token" "$file")
  </code></pre>
  
  <p>and I get the following error:</p>
  
  <pre><code>./parsingTrace: line 153: syntax error near unexpected token `('
  ./parsingTrace: line 153: `done &lt;&lt; (grep -w "pop" "$file")'
  </code></pre>
  
  <p>I do not want to pipe grep to the while, because I want variable inside the loop to be visible outside</p>