Forum Moderators: phranque

Message Too Old, No Replies

./ and ../

What's the difference?

         

dougmcc1

3:42 am on Sep 22, 2003 (gmt 0)

10+ Year Member



Whats the difference between ./ and ../?

marcs

3:48 am on Sep 22, 2003 (gmt 0)

10+ Year Member



./ is the current directory

../ is the directory one step up in the directory tree.

dougmcc1

4:03 am on Sep 22, 2003 (gmt 0)

10+ Year Member



Ah, ok. Thanks.

Why would you want to use./? For example, isn't "./page.htm"
and "page.htm" the same thing?

marcs

4:11 am on Sep 22, 2003 (gmt 0)

10+ Year Member



They are pretty much the same thing. However, there are cases where you'd want to call a script in the local directory and use the ./ part.

dougmcc1

4:16 am on Sep 22, 2003 (gmt 0)

10+ Year Member



Ok now we're getting somewhere :)

When would one want to use ./?

marcs

4:19 am on Sep 22, 2003 (gmt 0)

10+ Year Member



This is a bit of a silly example, but you'll see what I mean.

Say you write a script called 'backup' and a script with the same name is already on the server (in one of the exec paths).

If you issue a backup command, it would go to the default one. To execute yours, either specify the full path, or from within the directory ./backup

dougmcc1

4:39 am on Sep 22, 2003 (gmt 0)

10+ Year Member



So in other words it comes in handy when your files don't have file extensions?

txbakers

4:54 am on Sep 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



no, it has nothing to do with file extensions.

it has to do with the directory structure you set up for your site.

if you do: a href="backup.htm" it will take you to the backup.htm file in the same folder as the current page.

if you do: a href="../backup.htm" it will take you to the backup.htm file in the folder abouve the current page.

if you do: a href="../" it will take you to the default page of the directory one folder above.

if you do: a href="/" it will take you to the default page of the current directory

WebJoe

5:01 am on Sep 22, 2003 (gmt 0)

10+ Year Member



txbakers, you have a little typo there

if you do: a href="/" it will take you to the default page of the current directory

because
a href="/"
will take you to default page of the root directory, you probable meant
a href="./"

txbakers

1:45 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Webjoe - you're right! missed that one. Darn fat fingers.

Farix

12:58 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



I use href="./" a lot when I want to link back to the default or "starting" page of the directory. It keeps my HTML from being cluttered with href="index.htm" that I feel is largely unnecessary.

dougmcc1

1:19 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



Thanks guys.

Reflection

10:21 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



I use href="./" a lot when I want to link back to the default or "starting" page of the directory. It keeps my HTML from being cluttered with href="index.htm" that I feel is largely unnecessary.

Learn something everyday :)