After executing this query in Artifactory
/usr/bin/jfrog rt s foo/01_Develop/01_CI/HPCC-Package-*.zip
I have this output:
[Info] Searching artifacts...
[Info] Found 3 artifacts.
[
{
"path": "foo/01_Develop/01_CI/HPCC-Package-47.zip"
},
{
"path": "foo/01_Develop/01_CI/HPCC-Package-48.zip"
},
{
"path": "foo/01_Develop/01_CI/HPCC-Package-72.zip"
}
]
I want to get the last path in json array with this command as suggested here:
/usr/bin/jfrog rt s foo/01_Develop/01_CI/HPCC-Package-*.zip | jq .[-1].path
But fails with
parse error: Invalid numeric literal at line 1, column 6
I cannot change json as it is the output from artifactory jfrog tool
- How can I fix JQ query?
- Is there any other way to get the last path?
NOTE: I have jq version 1.5
UPDATE:
Using quotes I have the exact same error:
/usr/bin/jfrog rt s foo/01_Develop/01_CI/HPCC-Package-*.zip | jq '.[-1].path'
/usr/bin/jfrog rt s foo/01_Develop/01_CI/HPCC-Package-*.zip | jq ".[-1].path"
For the record, here's a jq-only solution that assumes there are exactly two lines of non-JSON prolog: