12

when we specify the file path some times we specify like ./filename and some time ../filename what is difference between these two?

5 Answers 5

22

../ refers to the parent folder while ./ means the current folder

1
  • 1
    they are just a shortcut, so you dont have to write out long directory names.
    – Keltari
    Aug 25, 2011 at 2:41
14

. means 'the current folder'.
.. means 'the folder containing the current folder'.

8

just in case you wonder, ./filename actually means the same thing as filename - however, on unix systems, the current path isn't searched for executables (for security reasons), so you have to explicitly say "look in the current directory"

3

Both are different. ./filename points to a file in current directory while ../filename points to a file in parent directory

2

Both ./ and ../ are the ways to describe a file-path. As all suggested above you can use ./ while your file is in the current folder and ../ while your specified file is in the parent directory. Generally, it is useful while your current folder and parent folder both contains the file with the same name. Then these are very helpful to get the exact file from the folder you have specified.

Ex.

  • image in current folder: "./profile1.jpg";
  • image in parent folder: "../Images/profile1.jpg:"

You must log in to answer this question.