linux命令积累之egrep命令
学搭建Nginx环境,必须要配置的Nginx.conf文件中,如下:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
一般我们初学的,不可能一下子把配置文件一下子搭出来。要逐个模块去了解,注释部分可以先去掉,接下来就可以用这个命令进行排除掉#和空行
语法
grep -v '#|^$' filename
egrep -v '#|^$' filename
命令的作用
grep, egrep, fgrep - print lines matching a pattern
参数:
-v, --invert-match 排除
-E, --extended-regexp
egrep -i 'devops' file 不考虑sam的大小写,含有sam的行.
egrep -l "dear ken" * 包含dear ken的所有文件的清单.
egrep -n tom file 包含tom的行, 每行前面追加行号.
egrep -s "$name" file 找到变量名$name的, 不打印而是显示退出状态. 0表示找到. 1表示表达式没找到符合要求的, 2表示文件没找到.
实例:
[root@web01 conf]# egrep -v '#|^$' nginx.conf.default > nginx.conf
[root@web01 conf]# cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
去掉注释#和空行后,看起来就舒服多了。
转载于:https://blog.51cto.com/520527/1880719
linux命令积累之egrep命令相关推荐
- linux中egrep命令的作用,linux命令积累之egrep命令(示例代码)
学搭建Nginx环境,必须要配置的Nginx.conf文件中,如下: #user nobody; worker_processes 1; #error_log logs/error.log; # ...
- linux中的grep和egrep命令,Linux之grep和egrep命令总结
grep / egrep 语法: grep [-cinvABC] 'word' filename -c :打印符合要求的行数 -i :忽略大小写 -n :在输出符合要求的行的同时连同行号一起输出 ...
- linux中egrep命令的作用,linux之grep和egrep命令
grep [-cnivrABC--color] 'word' filename --color可以把匹配到的内容字体换成彩色.-n :显示输出内容的行号-c :打印出符合要求的行数-v :打印不符合要 ...
- Linux常用的文本查找命令 find
一.常用的文本查找命令 grep.egrep命令 grep:文本搜索工具,根据用户指定的文本模式对目标文件进行逐行搜索,先是能够被模式匹配到的行.后面跟正则表达式,让grep工具相当强大.-E之后还支 ...
- linux中文本查找命令,Linux常用的文本查找命令 find
一.常用的文本查找命令 grep.egrep命令 grep:文本搜索工具,根据用户指定的文本模式对目标文件进行逐行搜索,先是能够被模式匹配到的行.后面跟正则表达式,让grep工具相当强大.-E之后还支 ...
- 【Linux】一步一步学Linux——egrep命令(50)
00. 目录 文章目录 00. 目录 01. 命令概述 02. 命令格式 03. 常用选项 04. 参考示例 05. 附录 01. 命令概述 egrep命令用于在文件内查找指定的字符串.egrep执行 ...
- linux中使用egrep取值ip地址,egrep命令_Linux egrep 命令用法详解:在文件内查找指定的字符串...
egrep命令用于在文件内查找指定的字符串.egrep执行效果与grep -E相似,使用的语法及参数可参照grep指令,与grep的不同点在于解读字符串的方法.egrep是用extended regu ...
- Linux grep/egrep命令详解
grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来 grep搜索成功,则返回0,如果搜索不成功,则返回1,如果搜索的文件不存在,则返回2. grep的规则表达式( ...
- linux egrep命令使用示例
egrep命令是grep命令的扩展版本,支持更多的正则表达式语法,并且可以查询多个文件. 以下是egrep命令的使用示例: 在文件中查找包含"hello"的行: egrep &qu ...
最新文章
- 统计计量 | 诺奖得主Angrist的因果推断课程文献读物单子
- HTML中Div、span、label标签的区别
- 编写一个判断素数的函数,在主函数输入一个整数时,输出是否素数的信息。...
- Nginx 服务优化与防盗链
- MySQL 数据存储文件
- 捕获异常VS抛出异常
- python入门if语句练习_python入门视频:09 if语句_练习.mp4
- python异常(高级) Exception
- 不要用偏执毁掉一个产业
- MyBatis映射文件3(参数处理Map)
- C语言之volatile用法(二十一)
- 第二个网站成长经历,http://www.chaomagou.com/ 潮妈购
- 安装IDM Integration Module插件
- 计算机ae软件的入门教学视频教程,新手如何入门剪辑?3分钟教会你快速上手(附赠教程)...
- 消息:阿里巴巴落户山东济南,注册资本1亿元
- 网络资源计算机教学设计,第11课 网络资源任我搜 教案
- Word文档中怎么删除空白页?删除空白页的五种方法
- ML Notes: Week 2 - Multivariate Linear Regression
- 三只大老虎和三只小老虎过河
- js 拖曳功能--代码解析