How to use xargs when the argument should be in the middle of the command

A lot of times (especially when working with kubernetes) happens that you need to extract certain arguments with one command and use them in the middle of another. A quick way to deal with it is through usage of xargs with -I arg.

For example:

kubectl get ns -o name | xargs -I "{}" kubectl label {} goldilocks.fairwinds.com/enabled=true

Copyright

Comments