The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 06-24-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184
This looks like a formatted print file complete with printer control codes.
We may need to convert the control characters to text before running a textual search. Also, we usually process an open ended list of files in "while" loop which also stops the script breaking if filenames contain space characters.
Try


Code:
ls -1d invALL.06* | while read FILENAME
do
       # sed -n l (character ell) converts control characters to text 
       count=`sed -n l "${FILENAME}" | grep -c 'Invoice Total'` 
       echo "${FILENAME} has ${count} Invoice Totals" 
done

I note that jim mcnamara has confined the search to lines starting "Invoice Total" which may already have fixed the problem! I may be delving too deep.

Last edited by methyl; 06-24-2009 at 07:04 PM.. Reason: Typo