What characters are forbidden in Windows and Linux directory names?
Windows
The following characters are forbidden in Windows directory (and file) names:
\
(backslash)/
(forward slash):
(colon)*
(asterisk)?
(question mark)"
(double quote)<
(less than sign)>
(greater than sign)|
(vertical bar or pipe)
Windows also restricts names that end with a period (.
) or space, and it has reserved device names like CON
, PRN
, AUX
, NUL
, etc., which cannot be used as valid directory or file names.
Linux/Unix
On Linux/Unix filesystems, practically any character is valid except:
/
(used as the path separator)- The null character
\0
Although these systems allow spaces, punctuation, and special characters, using them can make file management more cumbersome, so it’s still common to avoid them for convenience.
Recommended Resource
If you’re looking to strengthen your general coding skills and ability to handle all sorts of system quirks, you might find the following course from DesignGurus.io useful:
- Grokking Data Structures & Algorithms for Coding Interviews
A solid grounding in data structures and algorithms can make tasks like file and directory handling more intuitive and efficient, whether you’re working on Windows or Linux.
CONTRIBUTOR
TechGrind