Search code examples
shellkubernetesopenshift

How to get value of particular column value after running openshift command using shell script?


I am running below command in openshift platform which produces some output

oc get pods

name status

job1 Running

job2 Completed

How to extract only status from the above result and store it in a variable using shell script.

ex : status=completed


Solution

  • How to extract only status from the above result and store it in a variable using shell script.

    ex : status=completed

    Try status=$(oc get pods -o=custom-columns=STATUS:.status.phase --no-headers). You can echo $status and see the list of status saved in the environment variable.