Join Scott Simpson for an in-depth discussion in this video Search for text in files and streams with grep, part of Learning Linux Command Line.
- [Voiceover] One of the main reasons…we'd want to take a look at text files,…is to find some particular piece of information.…One tool you can use to do that is grep.…I just want to show you the basics here,…because you could spend hours…digging into all the powerful stuff grep can do.…At its most basic, grep prints lines of text…that match a pattern.…Sounds simple, right?…Well, a lot of the time it is.…I can use grep to search for a word…or phrase, which is really helpful…in going through configuration files or log files.…Or in our case, a poem.…
Let's have grep show us all the lines…of our poem's file that have the letters T, H, E.…To do this, I'll write grep,…and then the search term in quotes, "the,"…and then the name of the file I want to use.…And I can see in the results my search term…is highlighted.…And only lines of the file which contain that term…are shown on the screen.…To illustrate this a little bit better,…I'll run the same command again,…but add the -n option,…which numbers the output lines,…so we can see which lines of the original file…
This course will establish the foundation for more advanced Linux topics. Find other Linux training courses here.
- What is the Linux command line?
- Writing Linux commands at the prompt
- Finding help for Linux commands
- Editing files and folders
- Configuring user roles and file permissions
- Using pipes to connect commands
- Peeking at files
- Searching and editing text
- Finding disk and system information
- Installing and updating software