O'Reilly logo

SAMS Teach Yourself Unix in 10 Minutes by Robert Shimonski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required