Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

File system case sensitivity?

This is a question about file system case sensitivity

in file and directory names:


Will MacOS allow a file named 'file.txt' and a file

named 'File.txt' exist in the same directory

at the same time?


For that matter can a directory name 'aDirectory'

and an directory name 'adirectory' both exist in

the same directory at the same time?


I am confused because I am doing web related

dev work on localhost. I use php to validate the

existence of a file and use a name with a charater

in uppercase in the file name and php finds the file.


But, I use Fetch FTP client to upload a file with a

name the same as another file in the same location,

accept with a character set uppercase. It is successfully

placed according to the FTP client. It now looks like I

have both of the files in the same directory.

BUT, I delete one and both are removed.

Mac mini, macOS 10.13

Posted on Mar 17, 2020 12:47 PM

Reply
Question marked as Best reply

Posted on Mar 17, 2020 1:04 PM

No. MacOS is not a case sensitive file system by default. So you can't have two files named File.txt and file.txt. You can choose to configure the OS as case sensitive if you want to.

If you are using a case sensitive file system then File.txt is a different file than file.txt and mypage.php is a different file than MyPage.php. Most web servers are running case sensitive file systems so mysite/mypage.php

is not the same file as mysite/MyPage.php

File system formats available in Disk Utility on Mac - Apple Support

8 replies
Question marked as Best reply

Mar 17, 2020 1:04 PM in response to anotherJeff273

No. MacOS is not a case sensitive file system by default. So you can't have two files named File.txt and file.txt. You can choose to configure the OS as case sensitive if you want to.

If you are using a case sensitive file system then File.txt is a different file than file.txt and mypage.php is a different file than MyPage.php. Most web servers are running case sensitive file systems so mysite/mypage.php

is not the same file as mysite/MyPage.php

File system formats available in Disk Utility on Mac - Apple Support

Mar 18, 2020 4:52 PM in response to anotherJeff273

macOS uses a case-insensitive file system. So if you pass the full file name to the lowest level file system calls, the macOS file system drivers will do a case-insensitive lookup.


However, not all access to the file system is direct, especially if you are doing a search. Then it depends on the software doing the search.


For example the bash (and zsh) shell's if you give it a full file name (no wild cards) will just pass that to the file system and a case-insensitive lookup will occur.


But if you ask for a wild-card match, and your wildcard has the wrong case, the shell will not find the alternate spelling. This is because the shells evolved from the Unix world of case-sensitive file systems and they do not expect to find a file under alternate spellings. The shells want exact match.


Many other command line commands behave the way, again because of their Unix origins.


If your access to the file system is going through a language library, it is possible the library is implementing its own rules on what is a file name match and what is not.


I'm speaking as someone that has been developing and maintaining Unix file systems for 25 years, and a Mac owner for 35 years. I've had a chance to observe the idiosyncratic of case-sensitive vs case-insensitve up close and personal. 😀

Mar 17, 2020 1:31 PM in response to BobTheFisherman

I did try a test while I was waiting:

I made a copy of a file on the desktop and rename the

copy with on character set uppercase that wasn't upper

case in the original. The system would not let me do that.

The same was true for two directories with names the

same accept for character case differences.

So there isn't really an issue if the system won't allow

files and dirs with same name accept for character case

difference, in the same location at the same time. So

scripted file system searches won't be confused.

Mar 17, 2020 6:55 PM in response to anotherJeff273

If you are doing any type of multi-platform work, then you should always make sure everything you do can work on a case-sensitive file system. If you get into this habit early, then you never have to worry about the file system you are using. Even if you are only ever refer to a Mac file system right now, if you always create your files with case sensitivity in mind, then it will be much easier on you if you ever need to actually work on a case-sensitive file system.

Mar 17, 2020 11:58 PM in response to HWTech

Thank you, HWTech;


I have been intensely aware of case sensitivity, having been doing

programming in javascript on the client side and php on the server

side for some time. As a matter of fact that is what caused this

question to occur to me in the first place. I was expecting case

sensitivity in file system naming and didn't see it using javascript

and php to verify the existence of a file on the localhost system.


Thank you for your thoughts

JK

Mar 18, 2020 8:36 PM in response to HWTech

I've been using Macs since 1996. But I didn't start developement

in earnest until around 2003. Since then I have become familiar

with Linux systems and had several FreeBSD servers to serve

domain names I had, from home via static ips from my ISP.


However, there is A LOT to know and most of my experience

has been task oriented. So there is much 'under the hood'

that I don't have more than profunctory experience with:

such as using the terminal and searchs and such.

I was expecting case sensitivy when using php to locate

file name because of experience with BSD, and probably

Linux systems (it has been a while and not a whole lot

at that beyond using Linux for developement system).

Other than Mac I have used BSD systems for development

much more.

This has taken me by surprise because until not it has not

been an issue that I have had to deal with.


I am also one who could be rightly called an amateur, or

at least a hobbyist. I work exclusively alone and don't get

financially compensated. I just have a sense that I can do

something more produtive than computer games and chase

gossip on social media. I appreciate all the responses I get from

on line posts and queries.

Thanks for all the responses and thoughts.

JK

File system case sensitivity?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.