Use grep to search Linux files and directories smarter

You’re looking for that one file, the one that contains the all important information for your next meeting. Do you manually search all of your files? That will take time. Instead we use a little Linux command line magic. Grep is a pattern matching command that we can use to search inside files and directories for specific text. Grep is commonly used with the output of one command, piped to be the input of the grep command. For example we can search inside a file for a specific string of text using the less command, and pipe the output to grep.

In this how-to we will use the grep command and commonly added arguments to search for specific strings of data within files. We’ll begin by setting up a small directory of test files as searching an entire filesystem can take some time and create a lot of results.

Leave a Reply

Your email address will not be published. Required fields are marked *