Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Passing two arguments to another command in the same line

I need to pass two arguments to the same command. The output of the first command look like this:

BLA    BLE
A1     B2
A2     B3

Right now I using this for using the first argument

firstCommand | tail -n1 | awk '{print $1}' | xargs -I_ secondCommand _

But the secondCommand has changed and right now I need to pass a second argument

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

secondComman A --second B

Is this posssible using xargs?

I try multiple stackoverflow solution, but none with was succesful.

>Solution :

Add printing 2nd argument to awk and capture 2 arguments with xargs:

firstCommand | tail -n1 | awk '{print $1,$2}' | xargs -n2 sh -c 'secondCommand "$1" --second "$2"' _
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading