Workshop

The Workshop summarizes the key terms you learned and poses some questions about the topics presented in this chapter. It also provides you with a preview of what you will learn in the next hour.

Key Terms

exclusion set A set of characters the pattern must not contain.

inclusion range A range of characters a pattern must include.

left rooted Patterns that must occur at the beginning of a line.

regular expressions A convenient notation for specifying complex patterns. Notable special characters are ^ to match the beginning of the line and $ to match the end of the line.

wildcards Special characters that are interpreted by the UNIX shell or other programs to have meanings other than the characters themselves. For example, * is a shell wildcard and creates a pattern that matches zero or more characters. When prefaced, for example, with the letter X—X*—this shell pattern will match all files beginning with X.

Exercises

1:What wildcard expression would you use to find the following?
  • All files in the /tmp directory

  • All files that contain a w in that directory

  • All files that start with a b, contain an e, and end with .c

  • All files that either start with test or contain the pattern hi (notice that it can be more than one pattern)

2:Create regular expressions to match the following:
  • Lines that contain the words hot and cold

  • Lines that contain the word cat but not cats

  • Lines that begin with a numeral

3:There are two ways you could have UNIX match all lines that contain the words hot and cold: One method uses grep and one uses pipelines. Show both.
4:Use the -v flag with various grep commands, and show the command and pattern needed to match lines that:
  • Don't contain cabana

  • Don't contain either jazz or funk

  • Don't contain jazz, funk, disco, blues, or ska.

5:Use a combination of ls -1, cat -n, and grep to find out the name of the 11th or 24th file in the /etc directory on your system.
6:There are two ways to look for lines containing any one of the words jazz, funk, disco, blues, or ska. Show both of them.

Preview of the Next Hour

Starting with the next hour, you learn about another powerful and popular program in the UNIX system, a program so helpful that versions of it exist even on DOS and the Macintosh today. It fills in the missing piece of your UNIX knowledge, and, if what's been covered so far focuses on the plumbing analogy, this command finally moves you beyond considering UNIX as a typewriter (a tty). What's the program? It's the vi screen-oriented editor. It's another program that deserves a book or two, but in two hours, you learn the basics of vi and enough additional commands to let you work with the program easily and efficiently.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.65.65