Prerequisite Skills / Processing Text Streams and Files
Subtitles of the Movie
In this movie we take a quick look at three commands which can help you make the most of your text files. Grep, Sed, and Awk, they process text streams, they take a look inside files. Let's look at these one by one. The Grep command searches inside files, it reads them and then prints out lines matching a pattern. For example if you're looking for all users named Mike you could use Mike as a search term on the password database file. The output includes all users information associated with the word Mike. Naturally you can make the search more complex. Let's use my full name as a search term and it returns the one username with my full name. Note how I put quotes around the search term Mike Jang, let's see what happens if I take off the quotes. Grep searches for the term Mike in the file name Jang which doesn't exist so Grep complains and then it searches for the term Mike in the password database file. Next let's look at the Sed command it's a stream editor which can transform input from one file to output in another file. We want to transform the file name OS. Let's take a look at it. That's not what we want to see, it would be better if we substituted the word corvalt's or the word gates, with the stream command that's easy. We substitute for the word gates, the word corvalt's, we take the stream from the file named OS and direct the output to the file named BestOS. Now let's look inside the BestOS file. Isn't that better? Next the Awk command, it's more of a database manipulation tool, it allows you to identify the line with a keyword and then read out the text from a specified column. But you absolutely don't need a word. Take this Awk command for example. It uses the colon as shown in quotes as noted with a dash shef option. The colon is thus specified as glemdor, in other words it specifies the different columns. If you forget how that works look at ETC password, you see each column is delimited by colons, now back to the Awk command. When you use the colon as a delimiter and say OK let's print out the first column what do you get but a list of usernames. And as you remember that's from the first column of ETC password. You can further delimit the output using Mike as a search term. And you can the two usernames associated with the word Mike. Thank you and on to the next tutorial.
Tutorial Information
| Course: | Red Hat Certified Technician |
| Author: | Michael Jang |
| SKU: | 33785 |
| ISBN: | 1-933736-97-6 |
| Release Date: | 2007-07-24 |
| Duration: | 7 hrs / 103 lessons |
| Captions: | For Online University members only |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 81,350 Video Tutorials (20,800 free)
- Video Available as Flash or QuickTime
- Over 782 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 