I have this command
kubectl get ns -l app=sample-api | awk '/fast/{print $1}' |
xargs -I {} helm list --short -n {} | xargs -I {} helm delete -n ?? {}
Suppose that argument from first xargs is $1 and it gets subsituted in like helm list --short -n {$1}
and $2 is the argument of second Xargs and its gets substituted like
helm delete -n ?? {$2}
but i also want $1 to use like this in last comand
helm delete -n {$1} {$2}
is this possible ?
output of first xargs
name1
name2
name3
second xargs
chart1
chart2
chart3
>Solution :
I would simply break it up into a separate loop.
kubectl get ns -l app=sample-api |
awk '/fast/{print $1}' |
while read -r name; do
target=$(helm list --short -n "$name")
helm delete -n "$name" "$target"
done