I have the following directory structure
./a/unknown.txt
./b/unknown.txt
What I want to achieve is
cat {a,b}/*.txt
The problem is I don't know a and b in advance but rather I have them in an array like so
dirs=(a b)
Now, I'm trying cat ${dirs[@]}/*.txt but it doesn't work. I have also tried other variations of this without success. The closest I have got is cat ${dirs[@]/%//*.txt} but this doesn't expand the *. Adding eval in the beginning fixes things but I feel there needs to be a more clever way.
I know I can iterate thorugh dirs and achieve what I want but I'm not interested in this solution.