Sometimes in Linux, we have to look for the existence of a particular string over
a huge collection of files distributed in a directory hierarchy. Rather than opening each file and using Ctrl+F to look for the string, we can use a command to search through a huge collection of files at once.
When searching for a particular string within multiple files such as object files,
executables and text files, we can use the following command. The "word" is the
string which we need to find within the files of current directory and also its
child directories in the hierarchy.
find . -type f -exec grep -l "word" {} +
a huge collection of files distributed in a directory hierarchy. Rather than opening each file and using Ctrl+F to look for the string, we can use a command to search through a huge collection of files at once.
When searching for a particular string within multiple files such as object files,
executables and text files, we can use the following command. The "word" is the
string which we need to find within the files of current directory and also its
child directories in the hierarchy.
find . -type f -exec grep -l "word" {} +
No comments:
Post a Comment