怎么使用grep
命令过滤掉以空格开头的行,比如我想把这些注释都给删除掉再输出
location /ci/ {
# proxy_pass http://47.92.112.6:20005;
proxy_pass http://47.92.112.6:8055/;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
#try_files $uri $uri/ /index.html;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
我使用grep "^\s*[^# \t].*$" default
并没有起到效果
So easy:
Output:
更进一步,如果想删除所有的注释部分(包括行内
#
后面的内容),可以使用sed '/^\s*#/d; s/\s*#.*//'
Input:
Output: