양상헌:
Hello team,
Can you let me know when I have to use ’ and when for “” ?
looking at https://kubernetes.io/docs/reference/kubectl/jsonpath/
kubectl get pods -o=jsonpath=“{.items[][‘metadata.name’, ‘status.capacity’]}" <– double quote
kubectl get pods -o=jsonpath='{range .items[]}{.metadata.name}{”\t"}{.status.startTime}{“\n”}{end}’ <– single quote
kubectl get pods -o=jsonpath=“{range .items[*]}{.metadata.name}{‘\t’}{.status.startTime}{‘\n’}{end}” <– double quote
if I change from ’ to ", or from " to ', then I got parsing error.
Marco Tony:
'\n'
is a character. same for '\t'
Marco Tony:
what’s the failing one?
George Lazaroff:
ah man use single ’ outside the { } -
'{ .....}{"\n"}'
George Lazaroff:
double “” inside the {} are for \n - new line
양상헌:
on the second -o=jsonpath='{range <– single quote
but
on the third, -o=jsonpath="{range <– double quote
this is what I’m confused now…
George Lazaroff:
@양상헌 use ’ ’ single quote for {} -
-o=jsonpath='{ .......... }'
George Lazaroff:
inside the single quote you can use double quote “”
George Lazaroff:
that’s it
양상헌:
if you look at the lab, answer said double quote like below.
further that, If I use single quote, then I got error. this is why I ask this question to understand clearly… take a look at the screen capture…
George Lazaroff:
Yeah it’s normal because of spaces I think, try - @.context.user==“aws-user” not @.context.user == "aws-user
양상헌:
thanks for comments, George~ ^^