title: grep: invalid repetition count(s) when using while loop
body: <p>So I'm using a MacOS commandline and have two files</p>
  
  <p>File A.txt</p>
  
  <pre><code>A
  B
  F
  </code></pre>
  
  <p>File B.txt</p>
  
  <pre><code>&gt;A
  abcde
  &gt;B
  efghi
  &gt;C
  jklmn
  &gt;D
  opqrs
  &gt;E
  tuvwx
  &gt;F
  yz123
  </code></pre>
  
  <p>I want it to go through a while loop through file A.txt and only print the corresponding header and content from file B.txt</p>
  
  <pre><code>&gt;A
  abcde
  &gt;B
  efghi
  &gt;F
  yz123
  </code></pre>
  
  <p>This line works when I go through each line in File A individually.
  <code>grep -n "\A\,\&gt;\{x;p;}" B.txt</code></p>
  
  <p>But when I do this:
  <code>While read i; do grep -n "\$i\,\&gt;\{x;p;}" B.txt &gt;&gt; newfile.txt; done &lt; A.txt</code></p>
  
  <p>I get this error:
  <code>grep: invalid repetition count(s)</code></p>
  
  <p>What am I doing wrong?</p>