Easy shell line look for string
Hi Guys..
I have a folder with a lot of subfolders and php files and no php files... I need a command that will list all files in this main folder and look for a specific string inside of just the .php files. what's the best way to do that? Thanks |
Quote:
Code:
grep -H "<whatever string to look for>" *.php |
One command won't do it ... You'll need to write a small script. It may even be able to be one line long, but you'll need a small set of commands.
You'll need ls, cat, grep, and, depending on your methodology, perhaps additionally wc and others. You will probably also need man. |
You can try :
Code:
grep -rln <string> /path/to/folder | grep .php Maybe: Code:
find /path/to/folder -name "*.php" -print0 | xargs -0 grep -l <string> |
Quote:
Grep can recurse folders, but (based on the OP's question), they wanted to look inside the 'main folder' for all PHP files, and look in them for a string. That's grep...the -H flag returns which file names contain the string. |
Quote:
|
All times are GMT -5. The time now is 05:20 PM. |