天天看點

shell 格式化輸出nginx的編譯參數

指令

<code>nginx -V &gt; nginx.txt</code>

<code>cat -n nginx.txt  | sed -n </code><code>'5,18p'</code> <code>| awk </code><code>'{$1="";print $0}'</code> 

<code>| sed </code><code>'s/^[ ]*//g'</code>  <code>| tr </code><code>'\n'</code> <code>','</code> <code>| sed -n </code><code>'s/,//gp'</code> <code>| tr </code><code>" "</code> <code>"\n"</code>

結果

<code>configure</code>

<code>arguments:</code>

<code>--user=nginx</code>

<code>--</code><code>group</code><code>=nginx</code>

<code>--prefix=/usr/share/nginx</code>

<code>--sbin-path=/usr/sbin/nginx</code>

<code>--conf-path=/etc/nginx/nginx.conf</code>

<code>--error-log-path=/</code><code>var</code><code>/log/nginx/error.log</code>

<code>--http-log-path=/</code><code>var</code><code>/log/nginx/access.log</code>

<code>--http-client-body-temp-path=/</code><code>var</code><code>/lib/nginx/tmp/client_body</code>

<code>--http-proxy-temp-path=/</code><code>var</code><code>/lib/nginx/tmp/proxy</code>

<code>--http-fastcgi-temp-path=/</code><code>var</code><code>/lib/nginx/tmp/fastcgi</code>

<code>--http-uwsgi-temp-path=/</code><code>var</code><code>/lib/nginx/tmp/uwsgi</code>

<code>--http-scgi-temp-path=/</code><code>var</code><code>/lib/nginx/tmp/scgi</code>

<code>--pid-path=/</code><code>var</code><code>/run/nginx.pid</code>

<code>--</code><code>lock</code><code>-path=/</code><code>var</code><code>/</code><code>lock</code><code>/subsys/nginx</code>

<code>--with-http_ssl_module</code>

<code>--with-http_spdy_module</code>

<code>--with-http_v2_module</code>

<code>--with-http_realip_module</code>

<code>--with-http_addition_module</code>

<code>--with-http_xslt_module</code>

<code>--with-http_image_filter_module</code>

<code>--with-http_sub_module</code>

<code>--with-http_dav_module</code>

<code>--with-http_flv_module</code>

<code>--with-http_gzip_static_module</code>

<code>--with-http_secure_link_module</code>

<code>--with-http_degradation_module</code>

<code>--with-http_stub_status_module</code>

<code>--with-debug</code>

<code>--with-http_sysguard_module</code>

<code>--with-http_upstream_check_module</code>

<code>--with-http_lua_module</code>

<code>--with-http_dyups_module</code>

<code>--with-luajit-lib=/usr/lib</code>

<code>--with-luajit-inc=/usr/include/luajit-2.0</code>

解釋:

<code>awk </code><code>'{$1="";print $0}'</code>

輸出第2列至最後一列(即排除第一列)

<code> </code><code>sed </code><code>'s/^[ ]*//g'</code>

去掉行首的空格

<code>tr </code><code>'\n'</code> <code>','</code> <code>| sed -n </code><code>'s/,//gp'</code>

去掉換行符,先把換行符替換成逗号(或者#¥%&amp;等),然後再講逗号删除

      本文轉自Tenderrain 51CTO部落格,原文連結:http://blog.51cto.com/tenderrain/1967076,如需轉載請自行聯系原作者

繼續閱讀