2013-05-30 10 views
10

ルートディレクトリは/で、posixによれば、/とは別のディレクトリがあります。 ls /とls //の場合、出力は同じです。つまり、statと同じですが、cd /とcd //の場合、ディレクトリの内容は同じですが、異なっています。 それは私を本当に混乱させました。誰でも答えがありますか? Bash FAQからpath //とはどのように違うのですか/

+0

は、あなたは彼らが異なっていると言うの参照を提供することはできますか?また、あなたが "cd /"と "cd //"の違いがどういう意味ですか?あなたはどのように知っていますか? –

+0

@ MarkkuK。申し訳ありませんが、私はそれが明らかに言わなかった、それはpwdが変化しなかったことを意味します。だからdevnullは言った。あなたはそれを試すことができます。 – dspjm

+0

また、 "cd/usr"の代わりに "cd // usr"(たとえば)と入力すると "/ usr"になり、bashは "// usr"でpwdが "// usr "too ... – Tom

答えて

18

E10) Why does `cd //' leave $PWD as `//'? 

POSIX.2, in its description of `cd', says that *three* or more leading 
slashes may be replaced with a single slash when canonicalizing the 
current working directory. 

This is, I presume, for historical compatibility. Certain versions of 
Unix, and early network file systems, used paths of the form 
//hostname/path to access `path' on server `hostname'. 
+0

私のgit bashエミュレーション(技術的にはWindowsマシン)では、' ls -l // 'を試すと、マシンは利用可能なネットワーク全体を読み込んでリストしようとします。 –

関連する問題