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 -->
  #5 (permalink)  
Old 12-31-2008
foleyml foleyml is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 3
Quote:
Originally Posted by Christoph Spohr View Post
Try:

command:

Code:
for file in file11[0-3][0-9]2008 
do 
    printf "%s\n\n" $(sed s'#.*11\(..\)2008#11/\1/2008#' <<< $file) >> logfile
    grep "search_text" search/path/${file} >> LOG_FILE 
done

HTH Chris
Chris, this outputs the search string of each file all into the logfile also, but it's not inserting the header or the blank line in the logfile (to separate the data according to the file they came from). Below is your code modified to the actual search criteria. Sorry about the change in path and file name values:


Code:
for file in event_demon.PRD.11[0-3][0-9]2008
do
    printf "%s\n\n" $(sed s'#.*11\(..\)2008#11/\1/2008#' << $file) >> logfile
        grep "sa_ZALE_REFMT_8" /autos/autotree/autouser/out/${file} >> LOG_FILE
        done

I now just need to figure how to work in the 2 "echo" code lines from my first post.