O'Reilly logo

Linux and Unix Shell Programming by David Tansley

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

Chapter 7. Introducing regular expressions

As you become more familiar with UNIX or LINUX, there is one subject you will bump into repeatedly, and that is regular expressions. As you use the shell, the need to extract more than just a basic string from a file soon outgrows it. For example, you may want to extract a word where the first two characters are, say, upper case followed by four numbers. You cannot do this in the shell unless you use some form of regular expression.

In this chapter we will cover:

  • matching at the beginning and end of line;

  • matching sets of data;

  • matching only alpha or numeric or both; and

  • matching character ranges.

When we want to extract or filter text from a file or an output of a command we can use what is called regular ...

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