I want to format the output of the following command:
kubectl config get-contexts
so add a delimiter so i can parse it, i've tried YAML And Json but they aren't supported.
How can I format the data to be as follows:
CURRENT,NAME,CLUSTER,AUTHINFO,NAMESPACE,
,name1,cluster1,,clusterUser,,
*,name2,cluster2,clusterUser,,
You can use linux sed
to rearrange the data to be as follows:
[root@]# kubectl config get-contexts | tr -s " " | sed -e "s/ /,/g"
CURRENT,NAME,CLUSTER,AUTHINFO,NAMESPACE
*,kubernetes-admin@kubernetes,kubernetes,kubernetes-admin,