Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|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 '12 at 17:45
@Fox FreeBSD will dig into the devices as well, but will most likely spit out a warning and move on. – Tim Jan 11 '12 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 '12 at 5:31
@RoyceWilliams Good point! – Cyclone Jan 15 '12 at 8:29
up vote 1 down vote accepted

Did you mean:

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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