Я пытаюсь извлечь версию из 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"}])
Там вы можете найти версию: