I'm searching for the way to find a file that contains specified string text.

It should be fast as possible but its not that important.

I was reading the manual, and I've build something like that: grep my_string * -r and it works at all, but if there are many directories to search.

Are there any other ways to find a file that contains specified string in FreeBSD?

link|improve this question

there aren't many ways that could make searching for string faster, than grep. and if you want to search multiple directories, just list them ... grep -r string dir1 dir2 dir3, or just grep the string on the whole drive grep -r string / (this could take a long time though and i'm not sure if freebsd grep will dig into devices by default) – Fox Jan 11 at 17:45
2  
@Fox FreeBSD will dig into the devices as well, but will most likely spit out a warning and move on. – Tim Jan 11 at 18:24
The -x option will prevent find from descending into directories with device numbers different from the starting point of the find, so devices will be skipped. – Royce Williams Jan 15 at 5:31
@RoyceWilliams Good point! – Cyclone Jan 15 at 8:29
feedback

1 Answer

up vote 1 down vote accepted

Did you mean:

grep -rl my_search_pattern    my_dir1 my_dir2 my_dir3 my_another_file
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.