Skip to content

Commit 6262a5d

Browse files
authored
Update jsonpath.md
1 parent 5247eac commit 6262a5d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

content/en/docs/reference/kubectl/jsonpath.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,14 @@ kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{\"\t\"}{.status.
101101
{{< note >}}
102102

103103
JSONPath regular expressions are not supported. If you want to match using regular expressions, you can use a tool such as `jq`.
104-
Example currently not supported
105104

106105
```shell
107106
# kubectl does not suport regular expressions
108107
# The following command does not work
109-
kubectl get secrets -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}'
108+
kubectl get pods -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}'
110109

111110
# The following command achieves the same result
112-
kubectl get secrets -o json | jq '[needs actual example code writing before merge]'
111+
kubectl get pods -o json | jq -r '.items[] | select(.metadata.name | test("test-")).spec.containers[].image'
113112
```
114113
{{< /note >}}
115114

0 commit comments

Comments
 (0)