Using . and *

Let's look at building a new file to practice using regular expressions. In this example, we will use grep in conjunction with the . and * REs. Since REs will specify a method of matching, I will attempt to drive home the concept of REs with a search through a simple text file that you can create with the vi editor or emacs.

Make a file that has the current information within it:

Rob's Test File
Rob Shimonski
"aka Unix junkie"
2006
2005
2004
2003
2002
2001
2000
1999
1899

Once you have finished, save and name the file robtest.txt.

This file will serve as the data we will search to learn how to use REs. In this example, we will use the period (.), which can be used to match any character as a single unit, and the asterisk (*), which ...

Get SAMS Teach Yourself Unix in 10 Minutes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.