Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 如何从命令行获取Elasticsearch服务器版本_Bash_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Command Line Interface - Fatal编程技术网 elasticsearch,command-line-interface,Bash,elasticsearch,Command Line Interface" /> elasticsearch,command-line-interface,Bash,elasticsearch,Command Line Interface" />

Bash 如何从命令行获取Elasticsearch服务器版本

Bash 如何从命令行获取Elasticsearch服务器版本,bash,elasticsearch,command-line-interface,Bash,elasticsearch,Command Line Interface,有没有办法只获取Elasticsearch服务器的版本号。我知道您获得了JSON请求数据,但是否有办法解析该请求?仅获取版本号 curl localhost:9200 如果您有该实用程序,可以使用它解析json回复并输出纯文本字符串: curl -sS localhost:9200 | jq -r .version.number 通用脚本语言也可以实现同样的功能,但通常更笨重: curl -sS localhost:9200 | python -c 'import json, sys; pri

有没有办法只获取Elasticsearch服务器的版本号。我知道您获得了JSON请求数据,但是否有办法解析该请求?仅获取版本号

curl localhost:9200

如果您有该实用程序,可以使用它解析json回复并输出纯文本字符串:

curl -sS localhost:9200 | jq -r .version.number
通用脚本语言也可以实现同样的功能,但通常更笨重:

curl -sS localhost:9200 | python -c 'import json, sys; print(json.loads(sys.stdin.read())["version"]["number"])'

另一种不需要任何外部依赖项的方法是使用和
filter\u path
query string参数(从ES 1.6开始提供)和
awk
命令

curl -s -XGET 'localhost:9200?filter_path=version.number&pretty=false' | awk -F'"' {'print $6'}
这将返回:

2.1.1
2.1.1