V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
endoffight
V2EX  ›  问与答

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

  •  
  •   endoffight · May 19, 2015 · 2559 views
    This topic created in 4002 days ago, the information mentioned may be changed or developed.

    如下


    ➜ 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 replies    2015-05-19 14:40:31 +08:00
    lhbc
        1
    lhbc  
       May 19, 2015 via Android   ❤️ 1
    sed 's/\s+/\n/g'
    BOYPT
        2
    BOYPT  
       May 19, 2015   ❤️ 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
       May 19, 2015
    十分感谢~
    lhbc
        4
    lhbc  
       May 19, 2015
    忘了,+ 也要用 \
    sed 's/\s\+/\n/g'
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   794 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 20:26 · PVG 04:26 · LAX 13:26 · JFK 16:26
    ♥ Do have faith in what you're doing.