"/home" depending where you actually want to search.Įxpanding the grep a bit to give more information in the output, for example, to get the line number in the file where the text is can be done as follows: find. So in the examples above, you'd better replace ' /' by a sub-directory name, e.g. Warning: unless you really can't avoid it, don't search from '/' (the root directory) to avoid a long and inefficient search! Note: You can add 2>/dev/null to these commands as well, to hide many error messages. The Silver Searcher: ag 'text-to-find-here' / -l RipGrep - fastest search tool around: rg 'text-to-find-here' / -l Better try them, provided they're available on your platform, of course: Faster and easier alternatives The find command is often combined with xargs, by the way.įaster and easier tools exist for the same purpose - see below. \ 2>/dev/nullįind is the standard tool for searching files - combined with grep when looking for specific text - on Unix-like platforms. This will only search through those files which have. -e is the pattern used during the searchĪlong with these, -exclude, -include, -exclude-dir flags could be used for efficient searching:. ![]() ![]() -l (lower-case L) can be added to just give the file name of matching files.Do the following: grep -rnw '/path/to/somewhere/' -e 'pattern'
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |