I'm writing a bash script that uses helm history (Kubernetes tool) command to get the last revision number of my release. The output for the command is like this:helm history release    REVISION    UPDATED                     STATUS      CHART                       DESCRIPTION         1           Mon Feb 27 12:46:10 2017    SUPERSEDED  chart-solution-0.1.0-beta1  Install complete    2           Fri Mar  3 11:40:55 2017    SUPERSEDED  chart-solution-0.1.0-beta1  Upgrade complete    3           Fri Mar  3 11:41:02 2017    DEPLOYED    chart-solution-0.1.0-beta1  Upgrade completeThe expected result is to return only the number 3 (last value) from the REVISION column. I can do that for now using:helm history release | awk -v col=REVISION 'NR==1{for(i=1;i<=NF;i++){if($i==col){c=i;break}} print $c} NR>1{print $c}' | tail -n 13However, the column UPDATED is irregular (space separated items), and the above command only works because the REVISION column comes before UPDATED. If in future versions the helm history command change the order of columns, things can get messed.A simple example is if I a try to get the last value using the column STATUS, which comes after UPDATED:helm history release | awk -v col=STATUS 'NR==1{for(i=1;i<=NF;i++){if($i==col){c=i;break}} print $c} NR>1{print $c}' | tail -n 1MarThere is a way to get the correct last REVISION value even if the column order changes?
awk a value from irregular output by column name
text processing;awk;helm