How to find a file that contains the specified string in FreeBSD?

8,220

Did you mean:

grep -rl my_search_pattern    my_dir1 my_dir2 my_dir3 my_another_file
Share:
8,220

Related videos on Youtube

Cyclone
Author by

Cyclone

Updated on September 18, 2022

Comments

  • Cyclone
    Cyclone almost 2 years

    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?

    • Fox
      Fox over 12 years
      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)
    • Cyclone
      Cyclone over 12 years
      @RoyceWilliams Good point!