awk '!/^([[:space:]]*#.*)?$/' testfiletestfile :
Beginning line
Line starts with spaces
# Comment line
# Comment line starts with spaces
Line # with a comment
2 empty lines below
Ending line
Beginning line
Line starts with spaces
Line # with a comment
2 empty lines below
Ending line
awk '!/^([[:space:]]*#.*)?$/ {$1=$1;print}' testfileBeginning line
Line starts with spaces
Line # with a comment
2 empty lines below
Ending line