Learn Linux Shell Scripting - Fundamentals of Shell 4.4 by Sebastiaan Tammer

Learn Linux Shell Scripting - Fundamentals of Shell 4.4 by Sebastiaan Tammer

Author:Sebastiaan Tammer [Sebastiaan Tammer]
Language: eng
Format: epub
Tags: COM088010 - COMPUTERS / System Administration / Linux and UNIX Administration, COM046070 - COMPUTERS / Operating Systems / Linux, COM088000 - COMPUTERS / System Administration / General
Publisher: Packt
Published: 2018-12-31T05:13:15+00:00


Summary

This chapter explained regular expressions, and two common tools that use them under Linux: grep and sed.

We began by explaining that regular expressions are search patterns, used in combination with text to find matches. These search patterns allow us to search very flexibly in text where its contents are not necessarily known at runtime.

Search patterns allow us, for example, to look only for words and not numbers, for words at the beginnings or endings of lines, or for empty lines. Search patterns include wildcards, which can represent one or more of a certain character or character class.

We introduced the grep command to show how we can use the basic functionality of regular expressions in Bash.

The second part of this chapter dealt with globbing. Globbing is used as a wildcard mechanism for file names and paths. It has similarities with regular expressions, but also some key differences. Globbing can be used with most commands that deal with files (and, since most things under Linux can be considered files, this means almost all commands support some form of globbing).

The last half of the chapter described using regular expressions with egrep and sed. egrep, being a simple wrapper for grep -E, allows us to use extended syntax for regular expressions, which we discussed along with some often-used, advanced features of grep.

In contrast to default regular expressions, extended regular expressions allow us to specify the length of certain patterns and how often they repeat, as well as allowing us to use alternation.

The final part of this chapter described sed, the stream editor. sed is a complex but very powerful command, which allows us to do even more exciting stuff than grep.

The following commands were introduced in this chapter: grep, set, egrep, and sed.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.