Advanced Command Line Skills
The course is part of this learning path
This course covers a selection of more advanced command-line skills that you can use to become a more proficient Linux user. This course is part of the Linux Administration Bootcamp learning path, designed to get you up and running with Linux.
In this course, you will learn about the following features:
- Tab completion
- Repeat as root
- Rerun a Command Starting with a String
- Reuse Arguments
- Strip Out Comments and Blank Lines
- Reuse the Last Item from the Previous Command
- Anyone with intermediate knowledge of Linux who wants to learn more!
This is an advanced-level course so a good level of Linux knowledge is expected.
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.
Jason is the founder of the Linux Training Academy as well as the author of "Linux for Beginners" and "Command Line Kung Fu." He has over 20 years of professional Linux experience, having worked for industry leaders such as Hewlett-Packard, Xerox, UPS, FireEye, and Amazon.com. Nothing gives him more satisfaction than knowing he has helped thousands of IT professionals level up their careers through his many books and courses.