Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers



View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
    #3  
Old 02-13-2008
agn agn is offline
Registered User
 
Join Date: Feb 2008
Posts: 343
Thanks: 0
Thanked 20 Times in 20 Posts

Code:
grep $pattern *.log

But if you have thousands of files, it may break. In that case, you can use


Code:
find $dir -type f -name '*.log' -exec grep -o $pattern {} \;

OR


Code:
find $dir -type f -name '*.log' -print0 | xargs -0 grep -o $pattern