You want this:
mdfind -name .txt
You see, mdfind
automatically assumes wildcards, so you don't need to try to pass it a wildcard.
And it turns out that since you didn't shell-escape your *
, you weren't actually passing that wildcard to mdfind
like you intended. Instead, you were giving it to the shell, and the shell was "globbing", or replacing it with the list of files in your current working directory (/Users/somebody/
) that matched the pattern *.txt
. So how the shell was really calling mdfind
was probably something more like this:
mdfind -name 20160408_2.txt SomeOtherFile.txt YetAnotherFile.txt AndSoOn.txt