Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I pass the output of a bash command as parameters to another? [duplicate]

Tags:

bash

I have a program that returns me a list of file names. I need to pass these file's contents to another program.

I know how to use cat to pass content:

cat file1 file2 file3 | some_program

what I want to do is something like:

list=`get_file_list`
cat ${list} | some_program

Though doing the above will simply pass the content of the list variable, rather than the files' content.

like image 849
AriehGlazer Avatar asked Nov 03 '25 20:11

AriehGlazer


1 Answers

To pass the output of,a program to another you can use xargs, for example

     find . -name "myfile*" -print | xargs grep "myword" $1

This one searches for files called myfile* and look for a key inside of them.

like image 146
JayZee Avatar answered Nov 06 '25 09:11

JayZee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!