从 URL、HTML 或 JSON 中提取 Confluence 版本
Extract Confluence version from URL, HTML, or JSON
我正在尝试从 URL 等
中提取 版本
https://my.atlassian.com/download/feeds/current/confluence.json
这是我的 bash 脚本:
#!/bin/bash
# Get the actual version
url="https://de.atlassian.com/software/confluence/download"
actual_version="$(curl -s $url | grep -Po '(?<=version :)\d+' | head -1)"
echo $actual_version
不幸的是,它不只给我版本号。
知道如何以正确的方式做到这一点吗?
注意:问题根据评论进行了多项改进/修订。
TL;DR
这是从他们的 JSON 页面中提取版本的最终命令:
curl -s "https://my.atlassian.com/download/feeds/current/confluence.json" | grep -Po '(?<="version":")[^"]*' | head -1
6.11.0
详情
看看这个 url 返回 JSON 产品版本:https://my.atlassian.com/download/feeds/current/confluence.json
这是撰写本文时 JSON 来源的副本:
downloads([{"description":"6.11.0 - Linux Installer (64 bit)","zipUrl":"https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.11.0-x64.bin","tarUrl":null,"md5":"5ce76e5763b97b93db21ba447b5fb4f0","size":"564.1 MB","released":"12-Aug-2018","type":"Binary","platform":"Unix","version":"6.11.0","releaseNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Release+Notes","upgradeNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Upgrade+Notes"},{"description":"6.11.0 - Windows Installer (64 bit)","zipUrl":"https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.11.0-x64.exe","tarUrl":null,"md5":"71c6f1275cc4ed6089871e5a7fd1f09b","size":"564.4 MB","released":"12-Aug-2018","type":"Binary","platform":"Windows","version":"6.11.0","releaseNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Release+Notes","upgradeNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Upgrade+Notes"},{"description":"6.11.0 - Standalone (TAR.GZ Archive)","zipUrl":"https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.11.0.tar.gz","tarUrl":null,"md5":"4c245b2b1dcc18ec9aff483c708f937e","size":"510.4 MB","released":"12-Aug-2018","type":"Binary","platform":"Unix, Mac OS X","version":"6.11.0","releaseNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Release+Notes","upgradeNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Upgrade+Notes"},{"description":"6.11.0 - Standalone (ZIP Archive)","zipUrl":"https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.11.0.zip","tarUrl":null,"md5":"f6d08f93840b92a2fbf9ac0005f249fb","size":"512.4 MB","released":"12-Aug-2018","type":"Binary","platform":"Windows","version":"6.11.0","releaseNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Release+Notes","upgradeNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Upgrade+Notes"}])
在那里,你可以找到版本:
我正在尝试从 URL 等
中提取 版本https://my.atlassian.com/download/feeds/current/confluence.json
这是我的 bash 脚本:
#!/bin/bash
# Get the actual version
url="https://de.atlassian.com/software/confluence/download"
actual_version="$(curl -s $url | grep -Po '(?<=version :)\d+' | head -1)"
echo $actual_version
不幸的是,它不只给我版本号。
知道如何以正确的方式做到这一点吗?
注意:问题根据评论进行了多项改进/修订。
TL;DR
这是从他们的 JSON 页面中提取版本的最终命令:
curl -s "https://my.atlassian.com/download/feeds/current/confluence.json" | grep -Po '(?<="version":")[^"]*' | head -1
6.11.0
详情
看看这个 url 返回 JSON 产品版本:https://my.atlassian.com/download/feeds/current/confluence.json
这是撰写本文时 JSON 来源的副本:
downloads([{"description":"6.11.0 - Linux Installer (64 bit)","zipUrl":"https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.11.0-x64.bin","tarUrl":null,"md5":"5ce76e5763b97b93db21ba447b5fb4f0","size":"564.1 MB","released":"12-Aug-2018","type":"Binary","platform":"Unix","version":"6.11.0","releaseNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Release+Notes","upgradeNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Upgrade+Notes"},{"description":"6.11.0 - Windows Installer (64 bit)","zipUrl":"https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.11.0-x64.exe","tarUrl":null,"md5":"71c6f1275cc4ed6089871e5a7fd1f09b","size":"564.4 MB","released":"12-Aug-2018","type":"Binary","platform":"Windows","version":"6.11.0","releaseNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Release+Notes","upgradeNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Upgrade+Notes"},{"description":"6.11.0 - Standalone (TAR.GZ Archive)","zipUrl":"https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.11.0.tar.gz","tarUrl":null,"md5":"4c245b2b1dcc18ec9aff483c708f937e","size":"510.4 MB","released":"12-Aug-2018","type":"Binary","platform":"Unix, Mac OS X","version":"6.11.0","releaseNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Release+Notes","upgradeNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Upgrade+Notes"},{"description":"6.11.0 - Standalone (ZIP Archive)","zipUrl":"https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.11.0.zip","tarUrl":null,"md5":"f6d08f93840b92a2fbf9ac0005f249fb","size":"512.4 MB","released":"12-Aug-2018","type":"Binary","platform":"Windows","version":"6.11.0","releaseNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Release+Notes","upgradeNotes":"https://confluence.atlassian.com/display/DOC/Confluence+6.11+Upgrade+Notes"}])
在那里,你可以找到版本: