Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash command output as parameters

Assume that the command alpha produces this output:

a b c
d

If I run the command

beta $(alpha)

then beta will be executed with four parameters, "a", "b", "c" and "d".

But if I run the command

beta "$(alpha)"

then beta will be executed with one parameter, "a b c d".

What should I write in order to execute beta with two parameters, "a b c" and "d". That is, how do I force $(alpha) to return one parameter per output line from alpha?

like image 211
oz1cz Avatar asked Dec 11 '22 12:12

oz1cz


1 Answers

You can use:

$ alpha | xargs -d "\n" beta
like image 53
yolenoyer Avatar answered Dec 28 '22 18:12

yolenoyer