- 论坛徽章:
- 0
|
最近在学shell,在练习sed命令时想到一个问题
比如httpd.conf文件
</IfModule>
#
# "/usr/local/apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/usr/local/apache/cgi-bin">
AllowOverride None
Options None
#Order allow,deny
#Allow from all
</Directory>
#
# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value. If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain
下述二种情况的内容需要删除
1) 空行
2) 被注释的行内容, 这里包括#开头的,或者空格,TAB后马上接#的
试了好久,小弟只能通过两次命令才能完成,
$ sed '/^[[:space:]]*$/d' httpd.conf | sed '/^[[:space:]]*#/d' -
怎样才能一次匹配就能解决上面2种情况呢? |
|