Linux Administration Bootcamp
Installing and Connecting to a Linux System
Intermediate Linux Skills
Linux Boot Process and System Logging
Disk Management in Linux
LVM - The Logical Volume Manager
User Management in Linux
Networking With Linux
Shell Scripting with Linux
Command Line Kung Fu
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.