![使用 curl + awk 提取最新的 googleAppEngine](https://linux22.com/image/978045/%E4%BD%BF%E7%94%A8%20curl%20%2B%20awk%20%E6%8F%90%E5%8F%96%E6%9C%80%E6%96%B0%E7%9A%84%20googleAppEngine.png)
我正在尝试从中提取最新版本的谷歌应用引擎他们的目录。为此,我使用 curl + awk。我发现以下正则表达式提取了我需要的内容:/featured\/google_appengine_(.*?)\.zip/g
,但是当我尝试在里面使用它时:
curl -s https://storage.googleapis.com/appengine-sdks/ | awk '/featured\/google_appengine_(.*?)\.zip/'
我得到了全文,但没有featured/google_appengine_1.9.17.zip
,当我将其更改为
curl -s https://storage.googleapis.com/appengine-sdks/ | awk '/featured\/google_appengine_(.*?)\.zip{ print $1}/'
我什么都没得到。有人能指出我的错误吗?
答案1
此脚本摘录全部featured/google_appengine
按字母顺序排列的条目:
curl -s https://storage.googleapis.com/appengine-sdks/ | awk -F "featured/google_appengine_" '{ for (i = 2; i <= NF; i++) print $i }' | awk -F "<" '{print echo "featured/google_appengine_"$1}' | sort
例如:
featured/google_appengine_1.9.18.zip
featured/google_appengine_1.9.19.zip
如果您需要最新版本,请使用以下命令:
curl -s https://storage.googleapis.com/appengine-sdks/ | awk -F "featured/google_appengine_" '{ for (i = 2; i <= NF; i++) print $i }' | awk -F "<" '{print echo "featured/google_appengine_"$1}' | sort | tail -1
例如:
featured/google_appengine_1.9.19.zip
答案2
“featured/google_appengine_1.9.17.zip” 是您想要的吗?试试这个快速而简单的解决方案:
curl -s https://storage.googleapis.com/appengine-sdks/ | awk -F "featured/google_appengine_" '{print $2}' | awk -F "<" '{print echo "featured/google_appengine_"$1}'