Skip navigation

Want to Grep through the files of a directory and sub directories recursively?


find /your/path/here -name \*php -exec grep "text your searching for here" {} \; -exec ls -l {} \;

Explained:

find /your/path/here

(the beginning path)

-name \*php

(All files that end in php)

-exec grep “text your searching for here” {} \;

(For each php file found grep through looking for “text your searching for here” then echo the line)

-exec ls -l {} \;

(Echo the full location of the file)

About these ads

One Comment

  1. Grep actually provides a recursive option to accomplish the same thing much easier

    grep -R “test your searching for” /your/path/here

    That should save you a few keystrokes


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: