Skip to content
Advertisement

How can capture args with xargs across multiple pipe in bash

I have this command

JavaScript

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

JavaScript

but i also want $1 to use like this in last comand

JavaScript

is this possible ?

output of first xargs

JavaScript

second xargs

JavaScript

Advertisement

Answer

I would simply break it up into a separate loop.

JavaScript

As discussed in comments, if you need this in a Makefile, you’ll need to indent every line with a tab, double all the dollar signs, add semicolons between statements, and backslash-escape the internal newlines:

JavaScript

Unfortunately, Stack Overflow still renders tabs as spaces, so you will not be able to copy/paste this into a Makefile directly.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement