the docker and kubectl binaries have a filter switch built in. This is fairly basic on docker but good for piping output around for some more complex operations. Like if you have a lot of containers and forgot to add --rm
to one of them.
docker ps -aq --filter name=yolo | xargs docker container rm
Things get a little better with kubectl but not by much. template
is nice if you need to get a secret and you're not using encryption.
kubectl get secrets <secret-name> -o template --template='{{ .data.password }}' | base64 -d | pbcopy
If you want something more complex, like identifying a subset of a resource that need to have some action performed on them and then performing that action you usually need a script. This can be done with a one-liner though. The draw back to template
is that