Home > Articles > Home & Office Computing > Mac OS X

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Case Sensitivity and Case Preservation in Filenames

Where Mac OS X differs most visibly from other Unixes is in the way its filesystem (HFS+, for those of you keeping score) handles capitalization in filenames. Most Unix-style operating systems are case sensitive, meaning that a file called File1.txt is entirely distinct from one called file1.txt, and both can happily exist in the same folder. Linux or FreeBSD will see not the slightest similarity between those two files, no matter how much our human sensibilities might tell us that they're the same.

Mac OS X, like the classic Mac OS before it, is not case sensitive; it doesn't care whether you said File1.txt or file1.txt. Only one of them can exist in a folder at the same time, and there's no ambiguity for either computers or humans in telling which file you meant. Even Unix commands like ls will work if you give them filenames to operate on that don't match the capitalization of the actual files (try it: ls /library).

However, unlike some versions of Windows, Mac OS X is also case preserving. If you create a file called file1.txt, the system will keep it as file1.txt; it won't helpfully capitalize the first letter for you, it won't force the whole thing to uppercase or lowercase, and it won't lose track of the capitalization if you send the file through one application and then another, or up to a web server and back down again. Things stay the way you put them, but the system can generally figure out what you mean if you're less precise than it is. Unix purists who insist that the byte for "a" is as different from "A" as it is from "9" might grouse, but Mac OS X is just behaving the way humans do, isn't it?

Nonetheless, there's something weird about how Mac OS X's Unix shell lists files: it distinguishes between uppercase and lowercase letters when alphabetizing, and uppercase words come first in the ASCII code page. Thus, a file listing at the command line will be sorted differently from one in the Finder, with all the items whose names begin with capital letters listed before the ones in lowercase.

  • + Share This
  • 🔖 Save To Your Account