title: Using sed on a compressed file
body: <p>I have written a file processing program and now it needs to read from a zipped file(.gz unzipped file may get as large as 2TB),</p>
  
  <p>Is there a sed equivalent for zipped files like (zcat/cat) or else what would be the best approach to do the following efficiently</p>
  
  <pre><code>    ONE=`zcat filename.gz| sed -n $counts`
  </code></pre>
  
  <p>$counts : counter to read(line by line)</p>
  
  <p>The above method works, but is quite slow for large file as I need to read each line and  perform the matching on certain fields.</p>
  
  <p>Thanks</p>
  
  <h1>EDIT</h1>
  
  <p>Though not directly helpful, here are a set of zcommands</p>
  
  <p><a href="http://www.cyberciti.biz/tips/decompress-and-expand-text-files.html" rel="noreferrer">http://www.cyberciti.biz/tips/decompress-and-expand-text-files.html</a></p>