3 ms·
Not the op but here is an example: TOKEN=$(kubectl describe secret -n kube-system $(kubectl get secrets -n kube-system | grep default | cut -f1 -d ' ') | grep -
by ketanmaheshwari 11mo ago
Not the op but here is an example:
TOKEN=$(kubectl describe secret -n kube-system $(kubectl get secrets -n kube-system | grep default | cut -f1 -d ' ') | grep -E '^token' | cut -f2 -d':' | tr -d '\t' | tr -d " ")
This pipeline may be significantly reduced by replacing cut's with awk, accommodating grep within awk and using awk's gsub in place of tr.
- rbonvall 11mo agoExample of replacing grep+cut with a single awk invokation: $ echo token:abc:def | grep -E ^token | cut -d: -f2 abc $ echo token:abc:def | awk -F: '/^token/ { print $2 }' abc Conditions don't have to be regular expressions. For example: $ echo $CSV foo:24 bar:15 baz:49 $ echo $CSV | awk -F: '$2 > 20 { print $1 }' foo baz