V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
endoffight
V2EX  ›  问与答

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

  •  
  •   endoffight · 2015-05-19 13:31:03 +08:00 · 2141 次点击
    这是一个创建于 3280 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如下


    ➜ 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,求大神解答!

    4 条回复    2015-05-19 14:40:31 +08:00
    lhbc
        1
    lhbc  
       2015-05-19 13:49:22 +08:00 via Android   ❤️ 1
    sed 's/\s+/\n/g'
    BOYPT
        2
    BOYPT  
       2015-05-19 13:54:40 +08:00   ❤️ 2
    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
        3
    endoffight  
    OP
       2015-05-19 14:33:41 +08:00
    十分感谢~
    lhbc
        4
    lhbc  
       2015-05-19 14:40:31 +08:00
    忘了,+ 也要用 \
    sed 's/\s\+/\n/g'
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   968 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:16 · PVG 06:16 · LAX 15:16 · JFK 18:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.