2

Which is the fastest search method in linux to search (only) for a text inside whole linux file system (NOT JUST A SINGLE FILE) the search needs to be performed on all the files including the root binaries.

1 Answers1

1

I don't think you can find a faster way than a recursive grep:

grep -r foo /

That will search through each and every file on your file system for the word foo. You can speed it up a little by telling it to match only once per file with -m:

grep -rm 1 foo /

That way, if it finds a match in a file, it will print the matched line and move on to the next file, so it doesn't need to process the entire file each time, but it will always be slow unless you can somehow limit the number of files you want to search.

terdon
  • 242,166
  • I would recommend limiting that to directories where there is a higher likelihood of finding anything, never-mind what you're looking for. Specifically, depending on the flavor of Linux you're using, you're likely to waste some considerable time searching the "/dev" directory (devices) and the "/proc" directory (processes) among other places unlikely to match what you're looking for. – UncaAlby Sep 21 '18 at 03:15