Linux – Using underscore in file names

command linefile managementlinux

I use the command line frequently to navigate my files so I try not to have spaces in file names. Typically I have used an underscore to connect words but it was recently suggested that I should use a dash. Are there any disadvantages to using an underscore in file names? Should I switch to a dash? My system is running Xubuntu and I almost exclusively use the bash shell.

Thanks

Best Answer

As far as the operating system is concerned they both are as usable as each other.

One thing I would note - some software (such as some video playing systems - XBMC etc) will automatically replace underscores with spaces when displaying files to make them look nicer.

For that reason alone I'd be tempted to stick to underscores.

Also, hyphens are used for switches to commands, so it may be a little confusing having hyphens in you filenames as well as in your command switches.

Other than that it's purely down to personal choice.

Related Question