From the course: Learning Linux Command Line

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Search for text in files and streams with grep

Search for text in files and streams with grep - Linux Tutorial

From the course: Learning Linux Command Line

Search for text in files and streams with grep

- [Narrator] One of the main reasons we'd want to take a look at text files is to find and use some particular piece of information they contain. A popular command we can use to do that is grep and its most basic grep returns or outputs lines of text that match a search condition called a pattern. This pattern can be either a specific or explicit group of characters or they can use a pattern called a regular expression. We'll take a look at both briefly here, but grep is a hugely powerful tool and it's worth a course of its own. We'll take a look at the basics so you're prepared to dive in deeper if you want to. Let's use the grep tool to look for some texts in our poem exercise file. First, we'll have grep show us all the lines of our poems file that have the letters T, H, E. To do this, I'll write greb and then the search term in quotes And then the name of the file that I want to look inside of. And I can see in…

Contents