I'm not exactly sure if this is a "right" question to post here. I'm probably asking more about "opinions" than actual categorical answers (of those that either work or don't, and that's it).

I was wondering what name separators would be the most linux friendly (or more specifically, Bash friendly) and human friendly at the same time.

Let's say I want to create a directory that contains something related to Mr. Foo Bar (Foo being the first name, Bar being the last name)

Having the name "Foo-Bar/" is very convenient. - is a "regular" character, it doesn't need to be escaped, it clearly shows that Foo and Bar are two separate things... Nice.

Now, "Foo.Bar" is a bit trickier. Someone may think that Foo.Bar is actually a file (at a first glance, specially if you don't have terminals with coloring enabled) where "Foo" is the filename, and "Bar" the extension.

I could also use "Foo Bar", but then I need to escape the whitespace when I want to access the directory and, if I want to list the contents of the parent directory (where Foo Bar is located) and put said list in a bash array, the white space is going to cause trouble (a lot). Not nice.

Brackets () also cause a lot of issues. They also need to be escaped, then to cause trouble with commands as scp... Not nice.

So... the question (at last) is: If you need to make the name of a file clear and meaningful at a fist glance, and you need to use separators, what do you use?

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.
If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers
4

To make things easy to spot I tend to use a sequence of characters in areas where this is needed, the idea is to use something that is easy to spot so you get that this is the separator maybe something like "_-_" or "___".

A practical example where I use this is my mp3 collection where the filenames contain artist and song title, and sometimes the sequence number. And if you use a magic sequence to separate them it is easy both for the eye and for the scripts. The mp3 example could look something like this.

01_Blue_Man_Group_-_Above.mp3

02_Blue_Man_Group_-_Time_to_Start.mp3

03_Blue_Man_Group_-_Sing_Along.mp3

Now this can be translated into your example if Foo and Bar is two logical things that should not mix, and that could then be Foo_-_Bar.

With so many characters that you might not think should be special, in fact being special, I just use the special characters anyway. This also puts me in the good habits of using bash completion, where it will auto-escape all the special characters in a filename. But it also puts me in the good habits of escaping/quoting EVERYTHING in scripts and multi-part 1-liners in bash.

For example, in just a simple 1-liner:

for file in *.txt; do something.sh "$file"; done

That way, even if one of the files has a space, or some other character, the do part of the loop will still act on it, and not miss on 2 or more file-name-parts, possibly causing unintended side-effects.

Since I cannot control the space/not-space naming of EVERY file I encounter, and if I tried, it would probably break some symlinks somewhere, causing yet more unintended consequences, I just expect that all filename/directoryname could have spaces in it, and just quote/escape all variables to compensate.

So, then I just use whatever characters I want (often spaces) in filenames.

I even use spaces in ZFS dataset names, which I have to admit has caused a fair amount of head-scratching among the developers that write the software for the NAS I use.

Sum-up: Spaces are not an invalid character, so there's no reason not to use them.

I use dashes -, for the reasons you mention above. I avoid underscores because they require using the shift key, so take at least twice as long to type (also, I think they're ugly)

I'm more inclined to do this for script filenames than anything else - I guess it's more important to me to clearly identify what a script is for. Document files are just inert data, but scripts are potentially dangerous if misused.