Hacker’s Diary

Avatar

My Knowledge Database

[HowTo] Find files that contain a given string

If you are searching in current folder, sometimes command like:

cat * | grep -i “string” *

will print the filename and a line that matched the string. But this will not “search” in subfolders, and will not work on some Linux distros.

The right (my) way would be:

find /path/to/folder -type f -exec grep “string” {} \; -print

This will print a line that matched the string, and filename on the next line.

Bookmark and Share

No Comments, Comment or Ping

Reply to “[HowTo] Find files that contain a given string”

Protect yourself

FREE Online Scanner - Detect more than 3 million threats

Some useful ads

Before you go

Going so soon? May these links be a guide to web enlightenment. Schwing!