|
|
|
|
|
by stewartbutler
1628 days ago
|
|
Kinda-sorta related, you can pipe to a multivariable loop: paste <(printf "a\nb\nc\n") <(printf "1\n2\n3\n") | while
read x y; do echo "$y -- $x"; doneKinda silly for this example, but very useful in things like `kubectl` pipelines -- you can do something like this: kubectl get pods --all-namespaces | awk '{print $1 " " $2}' | grep "doesntexist" | while read x y; do kubectl delete pod $y --namespace $x --wait=false; done
This lets you list all pods in a cluster, grep a selection of them by name, and delete them in a batch, regardless of which namespace they are in, while shuffling the order of args into different flags. |
|