Search a string in files Linux

On linux, do you ever happen to want to find a string in a complete, ie multiple files?
Well believe me, if one day you must search an email address, an IP address, a piece of code, or otherwise, in thousands of files, this command will save you a lot of work manual.

Change to the directory where you want to search a string. And type the following command:

find . -name "*" -exec grep -Hn "nameofwhatareyousearchingfor" {} ;

Nameofwhatareyousearchingfor by replacing what you are looking for.

For example, if you want an IP address in your log files at once, you will :

cd / var / log
find. -Name “*”-exec grep-Hn “10.0.0.1″ {};

 

Leave a Comment