Linux command Accumulation egrep command

Source: Internet
Author: User
Tags sendfile egrep

Learn to build Nginx environment, you must configure the nginx.conf file, as follows:


#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;
}

In general, we are beginners, it is impossible to suddenly put the configuration files out. To understand each module, the comments section can be removed first, then you can use this command to exclude # and empty lines

Grammar

Grep-v ' #|^$ ' filename

Egrep-v ' #|^$ ' filename

Role of the command

grep, Egrep, fgrep-print lines matching a pattern

Parameters:

-V,--invert-match exclusion

-E,--extended-regexp

Egrep-i ' devops ' file does not consider the case of Sam, which contains a row of Sam.
Egrep-l "Dear Ken" * contains a list of all Dear Ken's files.
Egrep-n Tom file contains Tom's rows, with line numbers prepended to each line.
Egrep-s "$name" file finds the variable name $name, but does not print but shows the exit status. 0 means found. 1 indicates that the expression was not found to meet the requirements, and 2 indicates that the file was not found.

Instance:


[Email protected] conf]#egrep-v ' #|^$ ' nginx.conf.default > nginx.conf
[email protected] 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 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
}

After removing the comment # and the empty line, it looks much more comfortable.

This article is from the "Pcjazz" blog, make sure to keep this source http://520527.blog.51cto.com/510527/1880719

Linux command Accumulation egrep command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.