title: How do I grep GZ files to extract PNG files?
body: <p>Ok, so I have a tone of .GZ files in a folder, and I'm looking to recursively look through each one of them and extract all the PNG files into another destination folder. How would I do that? </p>
  
  <p>EDIT:</p>
  
  <p>I've been using this command from the terminal to find a string in a GZ file and copy the entire file to another destination directory. Then do stuff with it. There's a few drawbacks. One, when I put in "PNG", it finds files such as CSS files that reference "PNG" instead of file types. Second, it doesn't output anything to the directory except for copying the entire file.. I'd like to extract the file instead.</p>
  
  <pre><code>find . -type f -print0 | xargs -0 grep -lh "png" | xargs -I % cp % /some_destination
  </code></pre>
  
  <p>EDIT: </p>
  
  <p>Here's an example folder structure: </p>
  
  <blockquote>
    <p>FILE001.GZ, FILE002.GZ, FILE003.GZ, etc</p>
  </blockquote>
  
  <p>Not all of them contain PNGs, and some of them contain many files in a folder structure. What I want, is the following in another destination folder:</p>
  
  <blockquote>
    <p>34950560.png, 3959560.png, etc.</p>
  </blockquote>
  
  <p>Thank you ahead of time!</p>