I am trying to write a regex to pull all non-comment and non-empty lines from /etc/samba/smb.conf. Comments are lines that:
- start with #
- start with ;
- start with any amount of whitespace followed immediately by either # or ;
I tried the following, but it did not properly handle comment type 3.
grep -P '^\s*[^#;]' /etc/samba/smb.conf
This one worked for all 3 types of comments:
grep -P '^\s*[^#;\s]' /etc/samba/smb.conf
Can you explain why adding \s to the character class successfully filtered out comment type 3?