Happy Monday, everyone!
Let's kick off the week with a new RHCSA study mission. This week, we're focusing on a task that comes straight from the "Understand and use essential tools" section of the exam objectives: using grep
with regular expressions (regex) to analyze text.
My goal this week isn't to memorize every complex regex pattern. Instead, my mission is to master the fundamental building blocks, like the special meaning of ^
(start of line), $
(end of line), .
(any single character), and [ ]
(a set of characters).
man 7 regex
(The definitive guide to regex syntax is built right into the system!)
grep
command would you use on the /etc/ssh/sshd_config
file to find all lines that are not commented out and not blank?Let's get this week started!
The wrong answer:
grep -v '#' /etc/ssh/sshd_config
The easy answer:
grep '^[^#]' /etc/ssh/sshd_config
The smart answer: Add this alias to your shell login script:
decomment='grep -Ev "^[[:space:]]*((#|;|//).*)?$" '
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.