ls or find command do not seem to locate all files located in a specific folder. I'm running a Mac (under El Capitan 10.11.6 (15G21013), 500GB SSD, HFS+). In one of my folders, where I have about 700k files, I have a file that I can open, and ls or find will locate it if I specify the file name. However, ls or find applied on the folder will be unable to find the file. Does this look like a HFS+ corruption? What methods or tools are recommended to repair such an issue, with the minimum downtime, and risk for my filesystem?

11:16:35 gyin@mymac:[~/]: ls dis/ASA.md
11:19:06 gyin@mymac:[~/]: find dis/ASA.md
11:19:40 gyin@mymac:[~/]: find dis | grep "ASA.md"
11:19:55 gyin@mymac:[~/]: ls dis | grep "ASA.md"
11:20:36 gyin@mymac:[~/]: find dis | wc -l


Following Kamil's answer, it doesn't look like an Unicode issue.

13:28:12 gyin@mymac:[~]: find dis/ASA.md | xxd
00000000: 6469 732f 4153 412e 6d64 0a              dis/ASA.md.
13:28:25 gyin@mymac:[~]: echo dis/ASA.md | xxd
00000000: 6469 732f 4153 412e 6d64 0a              dis/ASA.md.
13:28:34 gyin@mymac:[~]:

1 Answer 1


Possible scenario:

There is А from Cyrillic script and there is A from Latin. They may look the same but they are coded differently.

If the second "A" in the troublesome filename isn't Latin, you may have typed like

ls dis/AS

then hit tab and your shell autocompleted the name with Cyrillic, you didn't even know the difference. You noticed this ls worked.

Next you hit , did an inline edit and turn ls into find, not touching the path (it still contained non-Latin character). You noticed find worked.

But when you type grep, you type ASA.md by hand. It's all Latin, there's no Cyrillic in it. Commands don't work as you expect.

I'm not saying it's A for sure. I'm saying one or more characters may not be what you think they are.

To confirm or dismiss this scenario I would analyze the hex output of the find command that works:

find dis/ASА.md | xxd

and compare to this command typed by hand:

echo dis/ASA.md | xxd

Note: my post does use the Cyrillic А in few places so don't copy and paste it mindlessly.

On the other hand your literal code posted in the question body seems to use dis/ASA.md in a coherent, Latin-only manner. If it was copied from the terminal (not typed independently), then my hypothesis probably doesn't apply to your particular case.

  • Thanks a lot Kamil. I just tried your xxd trick, typing the echo command by hand, and the outputs are strictly equivalent (see update in question). Anyway, upvoting for the interesting scenario and for the time spent.
    – Gerard Yin
    Jun 18, 2018 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.