Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Why lowercase the file name?


May 31, 2021 Article blog


Table of contents


Last week, the Chinese Technical Document Writing Code added the naming rules for files.

"File names recommend using only lowercase letters, not uppercase letters."

"For eye-catching purposes, some file names can be used in capital letters, such as README LICENSE

Netizens see, ask why the file name should be lowercase?

 Why lowercase the file name?1

To be honest, even though it's a Linux tradition, I've never really thought about why. Check the information quickly and find four compelling reasons to support doing so.

First, portability

Linux systems are case sensitive, whereas Windows and Mac systems are the opposite and case insensitive. Generally speaking, this is not a big problem.

However, if the two file names have different case and the others are the same, there is a problem across platforms.

  • foobar
  • Foobar
  • FOOBAR
  • fOObAr

The above four file names are treated as foobar by the Windows system. If they exist at the same time, you may not be able to open the next three files.

On the other hand, when developing on Mac systems, it can sometimes be negligent and misswritten.

// 正确文件名是 MyModule.js
const module = require('./myModule');

The code above works on the Mac because the Mac thinks MyModule.js and myModule.js are the same file. However, once the code runs to the server, the error is reported because the Linux system cannot find myModule.js

If all file names are lowercase, there will be no problems and the project will be well portable.

Second, readability

Lowercase file names are usually easier to read than capital file names, such as accessibility.txt than ACCESSIBILITY.TXT is easy to read.

Some people are used to using hump nomenclase, the first letter of a word capitalized, other letters lowercase. The problem with this approach is that it doesn't apply if you encounter acronyms that are all capitalized.

 Why lowercase the file name?2

For example, a New York special police officer surnamed Lee, whether written as NYPoliceSWATLee or NyPoliceSwatlee is strange, or written ny-police-swat-lee is more acceptable.

Third, ease of use

Some systems generate preset user directories with capitalized directory names. For example, Ubuntu generates directories such as Downloads Pictures Documents and so on by default in the user's home directory.

 Why lowercase the file name?3

Mac systems go too far, and some system directories are capitalized, such as /Library/Audio/Apple Loops/

In addition, some common profiles or description files also use capitalized file names, such as Makefile INSTALL CHANGELOG .Xclients and .Xauthority so on.

Therefore, the user's files are all in lowercase file names, it is convenient to distinguish from the above directories or files.

If you break the casserole to ask the end, why does the operating system use such a capital file name? T he reason is simple, because on earlier Unix systems, ls listed capital letters first, then lowercase letters, and capitalized paths came first. Therefore, if the directory name or file name is capitalized, it is easier for the user to see it first.

 Why lowercase the file name?4

Fourth, convenience

The file name is all lowercase and also facilitates command-line operations. For example, some commands may not use -i parameter anymore.

# 大小写敏感的搜索
$ find . -name abc
$ locate "*.htmL"


# 大小写不敏感的搜索
$ find . -iname abc
$ locate -i "*.HtmL"

 Why lowercase the file name?5

In addition, capital letters need to press shift key, more or less trouble. If the file name is lowercase, you don't have to touch this key, not only save trouble, but also improve typing speed.

Programmers use the keyboard for long periods of time, press shifting a few times a minute, saving a lot of finger movements in a day. Years and years, but also a kind of protection of their own bodies.

To sum up, it is the right thing to do to promote the use of all-lowercase-with-dashes conjunctional names.

Related reading