Artificial intelligent assistant

Cat files in subfolders in order given by a list I have a folder x with a number of sufolders ale, bae, galo and inside each subfolder one .pest file. x/ale/ale.pest x/bae/bae.pest x/galo/galo.pest I have a list in folder y containing the order I should cat .pest files bae galo ale from my x folder I'm trying for file in ./*/*.pest; do while read line; do cat "$line".pest; done; done <./y/list but it's not working.

To answer the follow-up subtly different question:

> I'm still wondering how would be if my subdirectories didn't have same names as in list though....

Let's make some assumptions:

* All the subdirectories of `x` are fair game.
* All `.pest` files are fair game.
* If you have two `.pest` files with the same name (but in different directories), you don't care what order those two files will be `cat`ed in.



Then you have:


while read -r name; do
cat x/*/"$name.pest"
done concatenated.pest


Adding sanity checking is a little bit trickier but still doable. (I'm not doing that part as I don't know if my assumptions even match your use case.)

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy b3b18969e79a234f51e999cef928a24e