Pregunta

For example, a directory has the following files: (as shown in explorer)

index.php
hello.php
img

If you query it using windows or just type dir in cmd prompt it will have the following files:

.
..
index.php
hello.php
img

I understand that '..' is a link to the previous directory, but what exactly is '.' and how can it be used? I've searched all over the internet, but no avail found for the single dot

¿Fue útil?

Solución

The . can be used in some commands: This will copy the files from c:\temp to the current directory:

copy c:\temp\*.* .

The .. can be used to move to a higher directory. This will change to the parent folder:

cd ..

Otros consejos

The '.' indicates the current directory as per this. As you mentioned, '..' is a link to the previous directory. Ultimately the Operating System will choose how to indicate these, but it is pretty standard across all major OSs

. is the same as the current directory, but in a relative way.

For instance if the current directory is c:\temp and if you cd in this directory, then . == c:\temp.

In short . is the current directory and .. is the parent directory. It is convenient for you to write scripts with these keyword otherwise you have to write a long command.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top