2

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?

SaveTheRbtz
  • 5,621
  • 4
  • 29
  • 45
Cyclone
  • 250
  • 1
  • 6
  • 20
  • 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
  • 2
    @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
  • 1
    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 05:31
  • @RoyceWilliams Good point! – Cyclone Jan 15 '12 at 08:29

1 Answers1

2

Did you mean:

grep -rl my_search_pattern    my_dir1 my_dir2 my_dir3 my_another_file
kubanczyk
  • 13,502
  • 5
  • 40
  • 55