From the course: Linux Tips

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Working with text: grep

Working with text: grep - Linux Tutorial

From the course: Linux Tips

Working with text: grep

- [Instructor] When working with text on a Linux system, we often need to search for a particular string in a log file, or some code, or a configuration file. And while it's always an option to open up a file and skim through it, there's a much better way, using a tool called grep. Before we look for text in a file, we need some text in a file. So I'll create a file with a few lines here before we get started. (typing) The most basic way to search a file with grep is to write out grep and then a search term, and the file to search within. I'll search for, let's say, the word line. I know that's in the file I just created. Using grep like this will show us the line of a file that matches whatever we're asking for. The match is highlighted in red here on my system. Depending on your terminal, you might see a highlight, or you might not. To specifically enable color output when you use grep, you can add dash dash color equals auto. And then your search and file. Or you can make an alias…

Contents