How to search the contents of files in GNU/Linux

Miguel Menéndez

To search for files in GNU/Linux that contain a specific string of characters, we usually use the grep command.

In the following example we will look for those lines that contain the text error (error) in the access.log file (/val/log/access.log):

# grep error /var/log/access.log

Obviously, what may interest us most is to search for a string of characters recursively in the content of all the files in a directory and its subdirectories:

# grep -R error /var/log/

See also

Comments

Found a bug? Do you think something could be improved? Feel free to let me know and I will be happy to take a look.