grep 命令示例——去掉注释

$ grep -v "^#" /path/to/config/file
$ grep -v "^#" /etc/apache2/apache2.conf

示例输出:

ServerRoot "/etc/apache2"
LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout
KeepAlive On
MaxKeepAliveRequests
KeepAliveTimeout
<IfModule mpm_prefork_module>
StartServers
MinSpareServers
MaxSpareServers
MaxClients
MaxRequestsPerChild
</IfModule>
<IfModule mpm_worker_module>
StartServers
MinSpareThreads
MaxSpareThreads
ThreadLimit
ThreadsPerChild
MaxClients
MaxRequestsPerChild
</IfModule>
<IfModule mpm_event_module>
StartServers
MaxClients
MinSpareThreads
MaxSpareThreads
ThreadLimit
ThreadsPerChild
MaxRequestsPerChild
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/

想要跳过其中的空行,可以使用 egrep 命令

egrep -v "^#|^$" /etc/apache2/apache2.conf

Linux查看配置文件中未被注释的有效配置行的更多相关文章

  1. Spring配置文件中未引入dubbo命名空间头部配置而引起的错误案例

    问题描述: Spring配置文件中未引入dubbo命名空间的头部配置而引起项目启动时报出如下错误信息: org.springframework.beans.factory.xml.XmlBeanDef ...

  2. Linux查看系统中的每个进程

    Linux查看系统中的每个进程 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ ps -A PID TTY TIME CMD 1 ? 00:00:01 init ...

  3. Linux查看目录中的文件

    Linux查看目录中的文件 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ ls examples.desktop jdk 公共的 视频 文档 音乐 java ...

  4. mysql linux查看配置文件my.cnf位置

    原文:mysql linux查看配置文件my.cnf位置 命令: mysql --help | grep 'Default options' -A 1

  5. Linux查看系统中socket状态

    当我们打开的socket数量很多时,netstat就会变得慢了,有什么办法可以快速查看系统中socket状态? IPv4: $ cat /proc/net/sockstat sockets: used ...

  6. Linux 查看运行中进程的 umask

    线上某台虚机因为故障重装了系统(基线 CentOS 6.9 内核 2.6.x),重新部署了应用.这个应用会生成一个文件,到NFS挂载目录. 而这个 NFS 挂载目录是一个 FTP 服务器的目录.另一台 ...

  7. linux查看日志中特定字符串以及前后信息内容命令

    在项目实施过程中,我们经常会查看日志,更是经常会根据某些特地字符串去查找日志内容. 下面就是日志查找命令: 1.查询字符串命令: cat fileName|grep '要查找的字符串' 实例:cat ...

  8. struts中如何查看配置文件中是否存在某个返回值

    ActionConfig config = ActionContext.getContext() .getActionInvocation().getProxy().getConfig(); Resu ...

  9. Linux 查看.so中导出函数

    方法一 nm -D  **.so 但这样能看到所有的导出,乱七八糟的很多,筛选用: nm **.so | grep XX 方法二objdump -tT **.so

随机推荐

  1. bzoj 2927: [Poi1999]多边形之战【博弈论】

    先手必胜状态是黑三角在边上 然后其他情况脑补一下,n为偶数先手必胜,可以理解为从某一边取,先手总有办法让后手取得一边有奇数个 #include<iostream> #include< ...

  2. thinkphp5 +elasticsearch

    php7使用elasticsearch 1.安装 官网下载地址:https://www.elastic.co/downloads/elasticsearch # 解压到非root目录,运行时使用非ro ...

  3. java中多线程的两种创建方式

    一丶继承Thread类实现多线程 第一步:继承Thread类第二步:重写run()方法第三步:创建继承了Thread类的对象 , 调用start()方法启动. //线程创建方式一 : /* 第一步:继 ...

  4. jQuery笔记之工具方法—高级方法Ajax

    $.ajxa() ——基本使用 前提:先了解js的执行机制 $.Callbacks()——回调 $.Deferred()——异步 $.when() 网络服务器链接由<渡一教育>提供 --- ...

  5. Mac 解登录密码Keychain

    在终端输入: security unlock-keychain -p "login pwd" ~/Library/Keychains/login.keychain 在制作macOS ...

  6. linux软件的安装。使用rpm、yum或wget下载软件

    介绍 在linux中安装软件一般有一下几种方式: a.通过rpm包安装 b.通过yum在线安装(联网) c.weget url 在线下载软件(只负责下载,不安装) 1.通过rpm包来进行软件的安装和卸 ...

  7. LVS集群-DR模式

    同上个实验一样,还是准备三台机器 分发器(sishen_63):eth0 192.168.1.63 RealServer1sishen_64) RealServer2sishen_65) 首先配置网卡 ...

  8. TRUNCATE DELETE DROP 区别

    TRUNCATE TABLE 在功能上与不带 WHERE 子句的 DELETE 语句相同:二者均删除表中的全部行.但 TRUNCATE TABLE 比 DELETE 速度快,且使用的系统和事务日志资源 ...

  9. PHP在不同页面间传递Json数据示例代码

    gettest.php文件: <?php $value["name"]= urlencode("我的姓名"); $value["pass&quo ...

  10. Maximal Discount

    Description: Linda is a shopaholic. Whenever there is a discount of the kind where you can buy three ...