Interview Prep/Real-World Interview/awk, sed, grep and jq one-liners

Delete all blank lines and comment lines from a config file and show what's actually active.

BeginnerHands-onawk, sed, grep and jq one-liners
Answer
grep -Ev '^\s*(#|$)' /etc/ssh/sshd_config
# or with sed
sed -e '/^\s*#/d' -e '/^\s*$/d' /etc/ssh/sshd_config

Key trick → One regex alternation (#|$) catches both comment lines and empty lines, including lines that contain only spaces.

All Real-World Interview questions Roadmap: Interview readiness

More on awk, sed, grep and jq one-liners