"How do I grep in specific file types?"

Post #302166849 by agn on Wednesday 13th of February 2008 12:35:29 AM

Old 02-13-2008
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