user3165155
user3165155

Reputation:

What difference in ./ ../ /

I searched around but didn't get satisfactory answer.

In directory structure i want to know what is the use of ./
It doesn't impact if I use this in src.

Please let us know difference in ./ ../ and /

Upvotes: 0

Views: 158

Answers (5)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201588

If this is about URLs, as it seems – the HTML attribute src takes a URL value – then it really has nothing to with directories. Interpretation of relative URLs takes place as string manipulation, without any reference to directories or files. (A resolved URL, absolute URL, may then be interpreted in a manner that maps things to a file system, but that is a different issue.)

At the start of a URL,

./ has no effect (it is removed in interpreting a relative URL)

../ causes the last part of the base URL, back to its last / in it, to be removed before using it as a prefix

/ causes the URL to be prefixed by the protocol and server part of the current base URL

Thus, assuming a base URL of http://www.example.com/foo/bar/zap,

./test.html resolves to the same as test.html, namely http://www.example.com/foo/bar/test.html

../test.html resolves to http://www.example.com/foo/test.html

/test.html resolves to http://www.example.com/test.html

Reference: STD 66.

If it happens that the absolute URLs are then interpreted, by the server running at www.example.com, in a simplistic (and common) manner by mapping them to a file system, then ./ maps to the same directory as the base URL, ../ maps to its parent directory, and / maps to the server root.

Upvotes: 1

Amarnath Balasubramanian
Amarnath Balasubramanian

Reputation: 9460

./ means the current directory

../ means the parent of the current directory, not the root directory

/ is the root directory

Explanation

myfile.text is in the current directory, as is ./myfile.text

../myfile.text is one level above you and /myfile.text lives in your root directory.

Upvotes: 1

Kaushik
Kaushik

Reputation: 2090

./ is the current directory.

../ is the parent directory of current directory.

/ is the root directory of the system.

You can also use __FILE__ and __DIR__ to get the path.

For more details look at this constants predefined

Upvotes: 2

Ted Hopp
Ted Hopp

Reputation: 234797

They work like this:

  • ./ — the current directory
  • ../ — the parent directory of the current directory
  • / — the root directory of the file system

Upvotes: 3

xdazz
xdazz

Reputation: 160843

./ is the current directory.

../ is the parent directory of current directory.

/ is the root directory of the system.

Upvotes: 11

Related Questions