In this course, you will learn how to install a Linux system and connect to it, whether that be on Mac or Windows.
We can strip out comments and blank lines with a grep command. We'll use the dash capital E option to enable extended regular expressions, V to invert our matches which means only print lines that do not match our search pattern, and we'll use this search pattern. In regular expressions, the carrot symbol represents the beginning of the line. So if we have a line that begins with a pound sign, we're not going to print it since we have the dash V option enabled. The pipe in regular expressions means "or" so if a line begins with comments, don't print it, or if we encounter a blank line, don't print it. And the blank line is represented by carrot again which means the beginning of the line and dollar sign, which represents the opposite, the end of a line. And then you would just specify the file that you're working on to strip out those comments and blank lines.
Let's look at an actual example. So find a configuration file. Well cat httpd.conf and then you can see here at the bottom there are comments. In the middle of the page you can see where there is a blank line. So let's run our command on this file. And then now you can see that it's all the data is compact. No comments, no blank lines. So before the file had 1009 lines in it, but once we strip out the comments and blank lines, it only contains 238 lines that contain real configuration information.
A world-leading tech and digital skills organization, we help many of the world’s leading companies to build their tech and digital capabilities via our range of world-class training courses, reskilling bootcamps, work-based learning programs, and apprenticeships. We also create bespoke solutions, blending elements to meet specific client needs.