1、 一个grep: cat /etc/sysctl.conf |grep -Ev "#|^$" 2、两个grep: cat /etc/sysctl.conf |grep -v "#" |grep -v "^$"