grep命令-v参数过滤以井号、分号开头的注释信息行及空白行

grep命令-v参数(反向选择)分别去掉所有以#(井号)和;(分号)开头的注释信息行,对于剩余的空白行可以再用^$来表示并反选过滤

[root@rhel7 samba]# cat smb.conf | grep -v "#" | grep -v ";" | grep -v "^$"
[global]
        workgroup = MYGROUP
        server string = Samba Server Version %v
        log file = /var/log/samba/log.%m
        max log size = 50
        security = user
        passdb backend = tdbsam
        load printers = yes
        cups options = raw
[homes]
        comment = Home Directories
        browseable = no
        writable = yes
[printers]
        comment = All Printers
        path = /var/spool/samba
        browseable = no
        guest ok = no
        writable = no
        printable = yes

 

posted on 2017-08-28 11:38  遠離塵世の方舟  阅读(6674)  评论(1编辑  收藏  举报

导航