I use mdfind
extensively to look for files on my file system because it is so much faster than find
. In this case, I was looking for README.md
files.
But today I just realized I was missing some files because they were actually symlinks.
Let me give you an example:
rm -rf test
mkdir test
cd test
touch foo.md bar.md test.txt test2.txt
ln -s test2.txt zoom.md
cd ..
OK, now if tree
it I see:
test
├── bar.md
├── foo.md
├── test.txt
├── test2.txt
└── zoom.md -> test2.txt
and using find test -name "*.md"
:
test/bar.md
test/foo.md
test/zoom.md
but mdfind -onlyin test -name md
doesn't match the symlink zoom.md
:
..../test/test/foo.md
..../test/test/bar.md
From this, it looks like specifying "kMDItemContentType == public.symlink"
might help. It didn't.
Looked around some more for kMDItemContentType
online, but Apple for some reason provides next to no documentation about mdfind
advanced usage.