Isolating lines

To display these lines encased with the tags, we can add a number range to sed. This is easily achieved by adding those numbers to sed, as shown in the following command:

$ sed -n '355,361 p ' httpd.conf 

With the range of lines specified, we have been able to easily isolate the lines that we required, and the only lines that are now displayed are those of the virtual host definition. We can see this in the following screenshot, which displays both the command and the output:

The issue that we face while hardcoding in the line numbers is that we lose flexibility. These line numbers relate to this file and maybe only this file. ...

Get Mastering Linux Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.