Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How linux handles multiple path separators (/home////username///file)

Do cd dir/subdir/ and cd dir/subdir// mean the same in UNIX?

Will the later work out? Else does it have any special meaning?

cd, mv, ls or any command for that sake.

share|improve this question

marked as duplicate by Gilles, Michael Mrozek Jun 2 '12 at 6:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

See also unix.stackexchange.com/questions/1910/… The question asks about Linux but Gilles' answer covers more. – Steven D Apr 25 '11 at 20:00
up vote 29 down vote accepted

Actually it means nothing and is ignored.

This often happens when output from multiple places is combined and it isn't clear who's job it is to add the slashes, so both parties do it and you end up with two of them. Semantically in the case of a directory path is has no meaning and will be ignored by most programs.

There are other situations in the unix world where they have meaning. Sometimes at the start of a path they could trigger a search for a samba path instead of a local file system path, or after a protocol in nfs they can indicate a hostname, however particularly in the case of a trailing slash like you gave as an example, it shouldn't matter much.

For the sake of your sanity as an administrator or programmer you should still avoid these cases wherever possible. You never know when something will be parsed incorrectly, but if one comes your way don't worry about it.

share|improve this answer
Exactly, I wanted to know whether I can keep it as double or single. i.e. double works on the current shell, but am not sure it will work on all the environments. So, it's better to have it single, then. Thanks a lot. – San Apr 25 '11 at 9:33
I suppose the difference is that anything operating on the file system will usually discern the reference to the same folder, but anything doing string matching on your path and not actually parsing it and looking at the disc might see this as different file. For example if you were comparing two files lists, you would want to normalize them by removing duplicate '/'s. If you are passing the string to cd, it won't care. – Caleb Apr 25 '11 at 9:37
I believe POSIX specifies any number of consecutive slashes collapse into one, but I'm uncertain, I do know both Linux and FreeBSD do it in the kernel. It's not the shell that cares. The cases where multiple slashes affects the interpretation are not local filenames. The example caleb gives of a samba path is actually a UNC path and it how Windows (which does not allow multiple slashes) interpret the path. This does not occur normally on UNIX systems as they don't natively support UNC paths. URLs are a different matter and multiple slashes do affect interpretations. – penguin359 Apr 26 '11 at 5:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.