Noob Question about grep

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
RCA86
Forum Commoner
Posts: 32
Joined: Thu Mar 10, 2011 1:03 pm

Noob Question about grep

Post by RCA86 »

Hey guys, I've googled this for a while, but haven't had much luck. The answer's probably really obvious, BUT...

I've just started a new job, part of which involves developing with the Interspire shopping cart, and I've found using grep really handy to search through the includes directories for function names, and references to their global variables system. Generally I want to search in httpdocs and recurse through directories looking only in PHP files, and sometimes HTML files. The problem is, there's a MASSIVE image directory (anybody who's ever used the ISC will know what I mean), and I want the search to completely ignore the images, or the directory. Here's what I've tried:

[text]grep -ir --include=*.php 'buildorderconfirmation' *[/text]

This finds what I want it to find, but it takes a long time to do it, so I suspect it's still searching the image directory, though I could be wrong. So do the 'include' and 'exclude' parameters just affect the results that are displayed, or do they actually tell it what files to look through, and which to completely ignore?

Cheers
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Noob Question about grep

Post by Darhazer »

you can try:

Code: Select all

find -regex .*\.php | grep -Roni 'buildorderconfirmation'
if it's not faster, the problem is in listing the directory contents, and not in parsing files (if there are thousand of files in single directory and you are using ext3 file system, you are in trouble)
Post Reply