With zsh
:
for dir in *(N/); do composer show drupal/$dir --available; done | ack version
The (N/)
part are glob qualifiers, N
for N
ullglob so you don't get an error if the glob doesn't match any file, /
to select files of type directory only. If you want hidden directories to also be included, add the D
(for D
otglob) qualifier.
Replace /
with -/
to also include symlinks to directories (like */
(which also works in other shells) does, except the expansion of */
also adds a /
at the end of each file).
Here's we're running ack
only once on the output of all composer
commands, as we don't need to run one for each. That also means that the overall exit status of that pipeline will reflect whether version
has been found at least once in any of them. If you moved | ack version
inside the loop, the overall exit status would reflect whether version
has been found in the last processed directory which would not be useful.