方法一:[root@centos conf]# sed -e '/^.*#/d' -e '/^$/d' httpd.conf
方法二:[root@centos conf]# cat httpd.conf | grep -v ^$ |grep -v ^.*#
方法三:[root@centos conf]# awk '$0&&$0!~/.*#/' httpd.conf
方法四:[root@centos conf]# awk '$0!~/^$/&&$0!~/.*#/' httpd.conf
转载于:https://blog.51cto.com/198293/1337521