The basics of regular expressions in Linux script

A sequence of characters that have certain patterns of text (with meta-characters) that are searched for in a larger text file are called regular expressions:

$ ll /proc | grep cpuinfo

In the preceding command, the grep utility will search for the cpuinfo text in all lines of input text and will print lines that have the cpuinfo text.

Utilities such as grep, sed, and awk use regular expressions for filtering text and then apply various processing commands as required by the user. The lines that do not match the pattern will be rejected. The following diagram explains the same concept:

regular expression linux concept

Related Articles

Calculating and reducing the runtime of a script

In this article, we are going to learn how to calculate and reduce the script’s runtime. A simple time command will help in calculating the execution time.PrerequisitesBesides having a terminal open, make sure you have the necessary scripts present in your...

read more

Lorem ipsum dolor sit amet consectetur


Submit a Comment

Your email address will not be published. Required fields are marked *

13 − 8 =