Results 1 to 5 of 5
Hello,
I would like to search inside a folder and its sub-folders for the name of a file that contains a specific text string.
What command should I run?
Thanks,
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-20-2007 #1Just Joined!
- Join Date
- Oct 2004
- Posts
- 11
Search file containing text
Hello,
I would like to search inside a folder and its sub-folders for the name of a file that contains a specific text string.
What command should I run?
Thanks,
David
- 12-20-2007 #2Code:
find -iname <string> find -iname *hello*
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 12-20-2007 #3Just Joined!
- Join Date
- Oct 2004
- Posts
- 11
String inside a file
Hi,
I didn't explain myself correctly. I don't want to find a "file name" that includes a string but rather the "name of a file" where the "file itself contains a string".
Thanks,
David
- 12-20-2007 #4It will fine string abc in all files in folder and subfolders.Code:
grep 'abc' -r *
Check manual of grep here. You can use sed for more efficient results but I am not familiar with it.It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 12-22-2007 #5Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
Not sure how a stream editor can give more efficient results than grep, but in casper's example use grep's -l option to get the names of the files containing the wanted string, rather than every matching line.


Reply With Quote
