39

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?

dan
  • 4,007
  • 5
  • 26
  • 34
  • When **I'm** naming them? Space. – Random832 Sep 24 '12 at 15:34
  • 8
    Traditional 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](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_276) 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
  • 1
    [This question](http://unix.stackexchange.com/questions/44153/good-style-practices-for-separators-in-file-or-directory-names) may be interesting. –  Sep 24 '12 at 19:46

1 Answers1

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,137
  • 5
  • 36
  • 35