如何格式化输出 nginx -V 的编译参数

2015-05-19 13:31:03 +08:00
 endoffight

如下


➜ nginx nginx -V
nginx version: nginxx/x.x.x
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --with-http_stub_status_module --with-http_sub_module --with-http_spdy_module


现在想把configure arguments一段输出打印成:

--prefix=/usr
--sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
...
..
.

主要是为了grep起来方便,之前见过类似命令,貌似用到awk还是sed,求大神解答!

2148 次点击
所在节点    问与答
4 条回复
lhbc
2015-05-19 13:49:22 +08:00
sed 's/\s+/\n/g'
BOYPT
2015-05-19 13:54:40 +08:00
nginx -V 2>&1 | sed 's/ /\n/g'
nginx
version:
nginx/1.6.2
TLS
SNI
support
enabled
configure
arguments:
--prefix=/etc/nginx
--conf-path=/etc/nginx/nginx.conf
--sbin-path=/usr/bin/nginx
--pid-path=/run/nginx.pid
--lock-path=/run/nginx.lock
--http-client-body-temp-path=/var/spool/nginx/client_body_temp
--http-proxy-temp-path=/var/spool/nginx/proxy_temp
--http-fastcgi-temp-path=/var/spool/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/spool/nginx/uwsgi_temp
--http-scgi-temp-path=/var/spool/nginxscgi_temp
--http-log-path=/var/log/nginx/access.log
--error-log-path=/var/log/nginx/error.log
--user=http
--group=http
--with-debug
--with-ipv6
--with-imap
--with-imap_ssl_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_dav_module
--with-http_gzip_static_module
--with-http_realip_module
--with-http_addition_module
--with-http_xslt_module
--with-http_image_filter_module
--with-http_sub_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_perl_module
--with-http_degradation_module
--with-http_geoip_module
--with-http_gunzip_module
--with-http_spdy_module
--add-module=../ngx_cachepurge
--add-module=../ngx_echo
--add-module=../ngx_headersmore
--add-module=../ngx_authpam
--add-module=../sysguard
endoffight
2015-05-19 14:33:41 +08:00
十分感谢~
lhbc
2015-05-19 14:40:31 +08:00
忘了,+ 也要用 \
sed 's/\s\+/\n/g'

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/192177

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX