If command1
is:
curl -k -v -u user:password https://example.com/v2/image/manifests/tag -H Accept: application/vnd.docker.distribution.manifest.v2+json 2>&1 | grep Docker-Content-Digest | awk '{print ($3)}'
which output, for example, the following Docker-Content-Digest
:
> sha256:12345...
knowing that running each command separately works, how to inject command1
output as part of command2
text as:
curl -k -v -u user:password -X DELETE https://example.com/v2/image/manifests/(command1 output)
I am just trying to run one command only!
Update:
When I combine them together using the double quote as following:
curl -k -v -u user:password -X DELETE https://example.com/v2/image/manifests/"$(curl -k -v -u user:password https://example.com/v2/image/manifests/tag -H Accept: application/vnd.docker.distribution.manifest.v2+json 2>&1 | grep Docker-Content-Digest | awk '{print ($3)}')"
I get the following output and command2
never executed:
> * Illegal characters found in URL
> * Closing connection -1
> * curl: (3) Illegal characters found in URL
Update 2
when I use single quote, I get the following output:
> < HTTP/1.1 404 Not Found
< Server: nginx/1.21.3
< Date: Tue, 28 Sep
> 2021 13:46:50 GMT
< Content-Type: text/plain; charset=utf-8 <
> Content-Length: 19
< Connection: keep-alive <
> Docker-Distribution-Api-Version: registry/2.0 <
> X-Content-Type-Options: nosniff < 404 page not found
echo "thisis$(echo "test")"
or better usingprintf
:printf 'thisis%s' "$(echo "test")"
– pLumo Sep 28 '21 at 13:11echo thisis$(command1)
– ralz Sep 28 '21 at 13:13curl
command. Consider showing that document. It's easier to parse JSON usingjq
than withgrep
andawk
. – Kusalananda Sep 28 '21 at 13:34