Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path separator for Windows and Unix

Tags:

Is there any special character that cannot be a part of the path in Windows or Unix that I can use it as a separator?

like image 656
user269354 Avatar asked Feb 09 '10 09:02

user269354


People also ask

What is the path separator for Windows?

All forward slashes ( / ) are converted into the standard Windows separator, the back slash ( \ ).

What is path separator in Linux?

If you prefer to hard-code the directory separator character, you should use the forward slash ( / ) character. It is the only recognized directory separator character on Unix systems, as the output from the example shows, and is the AltDirectorySeparatorChar on Windows.

What is a path separator?

The path separator is a character commonly used by the operating system to separate individual paths in a list of paths.

Which of the following is a file name path separator in Linux?

Around 1970, Unix introduced the slash character ("/") as its directory separator.


2 Answers

what about the delimiter for PATH environment variable? ; for windows, and : for linux.

like image 199
Dyno Fu Avatar answered Sep 28 '22 20:09

Dyno Fu


Wikipedia helpfully lists the reserved characters for different filesystems. Neither NTFS nor POSIX will accept the null or slash (/) characters in filenames. The slash character is obviously not a good separator, since it's common in POSIX paths, so maybe you could use null.

Of course null isn't suited to all situations (e.g. it isn't usually visible when printed), in which case you might have to use some sort of escaping scheme.

Java, which aims to work across different platforms, doesn't even try to find a common path separator. Instead each platform has its own character, accessible through an API.

like image 43
Rich Dougherty Avatar answered Sep 28 '22 19:09

Rich Dougherty