find, you can do:
LC_ALL=C find . -path '*/Contents/Database.json' -printf '%h\n'
%h gives you the
head of the path, that is the dirname.
LC_ALL=C is needed for
* to match any sequence of bytes regardless of what the user's locale regards as characters, as file paths can be made of any sequence of bytes other than 0 which don't have to make up characters in the user's locale.
zsh, also giving you a sorted list, excluding hidden ones, add also reporting symlinks to directories that contain a
print -rC1 -- **/Contents/Database.json(N:h)
For a closer equivalent to GNU
print -rC1 -- **/Contents(NDoN/e['
[[ -e $REPLY/Database.json || -L $REPLY/Database.json ]]'])
D includes hidden files (
order the list.
/ selects the files of type directory.
e['code'] checks that the dirs contain a
Database.json file of any type including broken sym
In any case, you cannot post-process the list like you do there. Instead, you'd do:
while IFS= read -ru3 -d '' file; do
something with "$file"
done 3< <(LC_ALL=C find . -path '*/Contents/Database.json' -printf '%h\0')
for file (**/Contents/Database.json(N:h)) something with $file