When you are naming files with multiple words in the name, is it more common in Unix systems to use underscores, camel case, or dashes to separate the words?
Asked
Active
Viewed 1.7k times
39
-
When I'm naming them? Space. – Random832 Sep 24 '12 at 15:34
-
8Traditional Unix commands and files don't tend to have more than one word at all. Most are a few letters. For your own files it is really up to you. I avoid spaces because they are a pain to deal with on the command line. The POSIX portable file name character set is quite restricted: alphanumeric, dot, underscore, and dash. – jw013 Sep 24 '12 at 15:39
-
As opposed to which naming method? – Karlson Sep 24 '12 at 16:38
-
1This question may be interesting. – Sep 24 '12 at 19:46
1 Answers
51
On one of my random systems:
$ find /usr/bin -xdev -type f -name '*-*' | wc -l # hyphen
1019
$ find /usr/bin -xdev -type f -name '*_*' | wc -l # underscore
311
$ find /usr/bin -xdev -type f -name '*[a-z][A-Z][a-z]*' | wc -l # camelcase
2
$ find /usr/bin -xdev -type f -name '* *' | wc -l # space
0
Your mileage may vary. There's a lot of personal preference involved -- my home directory is probably very much skewed towards hyphens, because underscore and camelcase involves shifting, and space has difficulties with quoting.

Jim Paris
- 14,337