title: How can I use grep and awk commands on a text file while maintaining line order?
body: <p>I have a text file that looks like this:</p>
  
  <pre><code>domain name pointer www.google.com
  domain name pointer www.gmail.com
  NA
  domain name pointer www.facebook.com
  NA
  NA
  NA
  domain name pointer www.starbucks.com
  </code></pre>
  
  <p>IF I use these commands:</p>
  
  <pre><code>grep "pointer" inputfile.txt | awk '{print $4}'
  
  grep "NA" inputfile.txt | awk '{print $1}'
  </code></pre>
  
  <p>I am able to get:</p>
  
  <pre><code>www.google.com
  www.gmail.com
  www.facebook.com
  www.starbucks.com
  NA
  NA
  NA
  NA
  </code></pre>
  
  <p>However I would like the 'NA' and URLS to stay in the same order as the original text file.</p>