Are there any invalid linux filenames?

前端 未结 3 1414
北海茫月
北海茫月 2020-12-05 06:13

If I wanted to create a string which is guaranteed not to represent a filename, I could put one of the following characters in it on Windows:

\\ / : * ? | &l         


        
3条回答
  •  情深已故
    2020-12-05 06:44

    An empty string is the only truly invalid path name on Linux, which may work for you if you need only one invalid name. You could also use a string like "///foo", which would not be a canonical path name, although it could refer to a file ("/foo"). Another possibility would be something like "/dev/null/foo", since /dev/null has a POSIX-defined non-directory meaning. If you only need strings that could not refer to a regular file you could use "/" or ".", since those are always directories.

提交回复
热议问题