- [Lecturer] Hi again,
and welcome to the next video of Section 4:
Printing Text between Line Numbers or Patterns.
In the previous video, we have learned
about the printing the nth word or column
in a file or line.
In this video, we'll see how to print text
between line numbers or patterns.
We may require to print a certain section of text lines
based on conditions such as a range of line numbers,
and a range matched by start and end patterns.
Let's see how to do it.
We can use utilities such as Awk, Grep, or Sed
to perform the printing of a section
based on conditions.
Still, I've found Awk to be
the simplest one to understand.
Let's do it using Awk.
Let's see how to do it.
To print the lines of a text
in a range of line numbers M to N,
use the following syntax.
Or, it could take a standard N you put as follows.
Replace M and N with numbers as follows.
To print the lines of a text
in a section with a start pattern and end pattern,
use the following syntax.
For example ...
The patterns used in Awk are regular expressions.
Also, we've successfully learned how to print
text between line numbers or patterns.
In the next video, we'll learn about
printing line numbers in the reverse order.