shell 格式化输出nginx的编译参数

命令

1
2
3
nginx -V > nginx.txt
cat -n nginx.txt  | sed -n  '5,18p'  | awk  '{$1="";print $0}' 
| sed  's/^[ ]*//g'   | tr  '\n'  ','  | sed -n  's/,//gp'  | tr  " "  "\n"

结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
configure
arguments:
--user=nginx
-- group =nginx
--prefix=/usr/share/nginx
--sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/ var /log/nginx/error.log
--http-log-path=/ var /log/nginx/access.log
--http-client-body-temp-path=/ var /lib/nginx/tmp/client_body
--http-proxy-temp-path=/ var /lib/nginx/tmp/proxy
--http-fastcgi-temp-path=/ var /lib/nginx/tmp/fastcgi
--http-uwsgi-temp-path=/ var /lib/nginx/tmp/uwsgi
--http-scgi-temp-path=/ var /lib/nginx/tmp/scgi
--pid-path=/ var /run/nginx.pid
-- lock -path=/ var / lock /subsys/nginx
--with-http_ssl_module
--with-http_spdy_module
--with-http_v2_module
--with-http_realip_module
--with-http_addition_module
--with-http_xslt_module
--with-http_image_filter_module
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_gzip_static_module
--with-http_secure_link_module
--with-http_degradation_module
--with-http_stub_status_module
--with-debug
--with-http_sysguard_module
--with-http_upstream_check_module
--with-http_lua_module
--with-http_dyups_module
--with-luajit-lib=/usr/lib
--with-luajit-inc=/usr/include/luajit-2.0

解释:

1
awk  '{$1="";print $0}'

输出第2列至最后一列(即排除第一列)

1
  sed  's/^[ ]*//g'

去掉行首的空格

1
tr  '\n'  ','  | sed -n  's/,//gp'

去掉换行符,先把换行符替换成逗号(或者#¥%&等),然后再讲逗号删除





      本文转自Tenderrain 51CTO博客,原文链接:http://blog.51cto.com/tenderrain/1967076,如需转载请自行联系原作者


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值