👤
Home Man
Search
Today's Posts
Register

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

How do I grep in specific file types?

 

 
Thread Tools Search this Thread
# 1  
Old 02-12-2008
How do I grep in specific file types?

I have a directory with file types ending .log, .mml, .gll, .dll . How can I grep expressions only in say the .log files?
# 2  
Old 02-12-2008
now i'm not 100% on this, but i'm fairly sure you can solve this issue by using pipe commands.

ls *.log | grep whatever whatever

the ls *.log will find only the files ending with .log, and whatever output you get from this, is carried over by the "|" and lets you manipulate it further.

Hope that helped.
# 3  
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

# 4  
Old 02-18-2008
Thanks agn, that worked.
 

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Copying specific file types to specific folders Mr_Keystrokes Shell Programming and Scripting 8 03-06-2018 03:46 PM
Help with Grep Specific Date From One File Into A New One DennisG34 UNIX for Beginners Questions & Answers 3 02-21-2018 10:28 AM
Grep in a specific file in an archive Subbeh Shell Programming and Scripting 1 06-13-2014 09:50 AM
Recursive grep with only certain types of files cokedude UNIX for Advanced & Expert Users 5 01-20-2014 03:45 PM
Help with using different types of GREP SilvarHawke Homework & Coursework Questions 11 11-29-2011 07:08 AM
grep specific ipaddress from a file tbd UNIX for Dummies Questions & Answers 1 11-20-2011 06:02 PM
Grep from specific column in one file based on another file [Please help!] Zoho UNIX for Dummies Questions & Answers 2 07-15-2011 07:31 PM
Help with grep at specific field of a file techmoris Shell Programming and Scripting 7 10-21-2010 11:21 AM
grep a specific line from a file Max89 Shell Programming and Scripting 4 11-24-2009 12:31 PM
grep on specific line of the file rider29 Shell Programming and Scripting 4 05-29-2008 09:57 AM


All times are GMT -4. The time now is 12:43 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password