i have several patterns that include ** wildcard, let them be:
foo/**/bar.xml
foo/**/baz.xml
and i have an example dirtree:
$ tree foo/
foo/
└── deep
├── baz.xml
└── even
└── deeper
└── baz.xml
what would be easiest way to check if any of those patterns is fulfilled? to be precise: return nonzero only if none is found. what I came up with so far is to use globstar and nullglob. But ls is not an option here, as if no pattern is satisfied, is lists current directory. So i had to utilize echo, like this:
$ (shopt -s globstar nullglob; echo foo/**/bar.xml foo/**/baz.xml) | grep .
foo/deep/baz.xml foo/deep/even/deeper/baz.xml
$ echo $?
0
vs
$ (shopt -s globstar nullglob; echo foo/**/bar.xml foo/**/beque.xml) | grep .
$ echo $?
1
so yeah - it works. but maybe i missed something and there is simpler/more elegant way to achieve this?