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 ^ (Again) and $

Let's learn how to do more with REs, but match the start and end of a line with the ^ (again) and $ characters.

In order to uniquely match the years specified in the sample file, you can use the start-of-line and end-of-line regular expression characters to stop grep from matching items you do not want matched. For example, if my phone number was in the sample file, I would not want it specified and I can do that with REs.

The characters ^ and $ are commonly referred to as anchors. To anchor something would be to fix something firmly and stably. They will anchor a pattern to the start or end of a line. 1899 and 1999 are both at the beginning of a line so doing this will not be difficult, and will show you the way these REs ...

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