grep
从文件或者管道中筛选出需要的信息 -v 显示不匹配的行,或者说排除某些行,显示不包含匹配文本的所有行 -n 显示匹配行及行号 -i 不区分大小写 -c 只统计匹配的行数 -E 使用扩展的egrep命令 --color=auto 为grep过滤的匹配字符串添加颜色 -w 只匹配过滤的单词 -o 只输出匹配的内容
~/Desktop grep -n 'andy' /etc/passwd
41:andy:x:1000:0:andy,,,:/home/andy:/bin/zsh
⚡ root@VM ~ grep -Ev "#|^$" /etc/nginx/conf/nginx.conf
user root;
worker_processes 3;
pid /etc/nginx/logs/nginx.pid;
events {
worker_connections 4096;
}
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;
}
}
include conf.d/*.conf;
}