Which characters are allowed and which of them must be escaped on the command line in different operating systems?
There's a discussion of filename characters in the Wikipedia article on File Names.
You may find this essay informative: Fixing Unix/Linux/POSIX Filenames.
This article compares OS X and Windows XP: X vs. XP: Forbidden Characters in Filenames (PDF, see pp approx. 64-66).
I don't know which characters must be un-escaped, but in Linux, it's probably not a good idea to escape the characters that may have special meaning such as "n" (newline), "t" (tab) and others, but that's generally not a problem in file operations. Perhaps you mean "escaped" rather than "unescaped". The most common ones are ones that the shell will interpret such as space, ">", "<", etc. See some of the articles I linked for a discussion of those.
The only characters not allowed in a filename in *nix are
/. In Windows, only
\ are truly not allowed, but many apps restrict that further, also preventing
At no point do any characters in a filename need to be escaped except as required in order to not be interpreted by the shell.
If you create a file on Windows with Explorer using one of the following characters, it will complain that the characters are not allowed:
\ / : * ? " < > |
A good reference is here:
Naming Files, Paths, and Namespaces
Microsoft further states:
"... on Windows-based desktop platforms, invalid path characters might include ASCII/Unicode characters 1 through 31, as well as quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t)."