The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 11-07-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,893
Quote:
Originally Posted by ali560045 View Post
need help in a command. My requirement is that i m grepping the filename based on a pattern in .tar.gz file and then copying the file into some dir

below is what exactly i want to achieve

step 1: grep -l '30017A6800022D1A' CurrentCollectorMeterReadBackup20081007.tar.gz

step 2: file found should be copied to dir nav/files

How to achieve the above steps without unzipping the file ? Plz help me in this

Code:
zcat CurrentCollectorMeterReadBackup20081007.tar.gz  | grep -l '30017A6800022D1A' && cp CurrentCollectorMeterReadBackup20081007.tar.gz nav/files/

However, I'm not sure if you want to copy a FILE named 30017A... or the file CONTAINING this. Either way, you need to put this into a loop which tests against either each file in the directory, or each record that will be matched.