From 6262a5dae36c6b459dfe403acc12d984c298266a Mon Sep 17 00:00:00 2001 From: Daniel Mendes Date: Tue, 18 Aug 2020 19:59:10 +0200 Subject: [PATCH] Update jsonpath.md --- content/en/docs/reference/kubectl/jsonpath.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/content/en/docs/reference/kubectl/jsonpath.md b/content/en/docs/reference/kubectl/jsonpath.md index 6ca252082d..acb9d9e9e9 100644 --- a/content/en/docs/reference/kubectl/jsonpath.md +++ b/content/en/docs/reference/kubectl/jsonpath.md @@ -101,15 +101,14 @@ kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{\"\t\"}{.status. {{< note >}} JSONPath regular expressions are not supported. If you want to match using regular expressions, you can use a tool such as `jq`. -Example currently not supported ```shell # kubectl does not suport regular expressions # The following command does not work -kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' +kubectl get pods -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}' # The following command achieves the same result -kubectl get secrets -o json | jq '[needs actual example code writing before merge]' +kubectl get pods -o json | jq -r '.items[] | select(.metadata.name | test("test-")).spec.containers[].image' ``` {{< /note >}}