Hi Beckett,
You haven't misunderstood what these options do. You're running up against a known limitation in the way that `--recursive` and `--filter` behave when combined.
The filtering done by `--filter` is done on each stage of the listing, and directories are *not* excluded. That means that if "/foo/" is a directory containing "bar/" (a directory) and "baz.txt" (a file), then
$ globus ls --filter '*.txt' --recursive "$endpoint:/foo/"
will do a filtered listing, finding only "baz.txt" and filtering out "bar/". When the results of that listing are checked for recursion (i.e. "are there directories in this ls result to traverse?"), "bar/" has already been filtered out.
We're aware that this is surprising, and not what most users expect when combining these two options. The behavior you were probably expecting, that `--filter` only gets applied to files, is something we've discussed in the past and is in our feature backlog.
I'm raising this with our team to see if we can prioritize support for that behavior.
In the meantime, the best two approaches I can recommend are:
1. Do a recursive ls and filter the results with `grep`, `awk`, or other unix tools
As you mentioned, this is easy and lightweight.
2. Write a script with the globus-sdk
If you are comfortable writing python, we have an
Example of Recursive LS in the docs which would be a good starting point. You could extend this to add filtering either client-side (similar to `grep`) or by making two calls for each directory -- one filtered to directories and one filtered to files matching the desired pattern.
There are issues with both of these approaches, and cases in which either one might run into performance issues. However, for most simple cases in which the `ls` calls return quickly, either one should work adequately.
Best,
-Stephen