What is the difference between "~/" and ".. /" for directory navigation?

Asked

Viewed 1,479 times

1

I saw it somewhere, I wanted to know the difference.

  • 2

    Are you referring to a *NIX system? Or is it something else? The only ~ that I know refers to the folder home user on those systems, and the same convention is not used on Windows (as far as I know). Other systems may have different conventions (I read in a comment below that Asp.net uses ~/ to name the root of the application). On the other hand, the .. is more or less standardized everywhere, so there is no doubt.

1 answer

1


Hi, come on, the / refers to the root of the OS directory (Unix architecture, in this case, via console), only the / access the root of your project, and, ../ the level above, see this practical example:

Imagine that you are creating a web application and have the following folder structure:

css
    style.css
    reset.css
images
    logo.png
    sprite.png
javascript
    main.js
    jquery.js
index.htm
about.htm

Now you want to format the class "logo", where, such class will have as background image the file logo.png (that’s in the folder images). Such a class will be part of the style.css file, it would look like this:

.logotipo {
        background: url('../images/logo.png');
}

To finish, the file style.css is in the folder css, and, to access the folder images it is necessary to return a level (so we use '../'), and after that access the folder with the logo, it was clear?

Hope I helped, hugs.

  • A worth this of .. / I already knew, just wanted to know the ~/ and this part was not clear.... It would be the root of the server?

  • 1

    A, I think I get it. Thanks then!!!!....

  • 5

    Would you have some reference for us to consult? I always understood that / was the root of the server, and ~ the user home folder. . the current directory (i.e. the directory itself) and .. the folder just above (the parent folder). But of course, different technologies can have different conventions, hence the confusion (and the need for a reliable reference, to better base the answer).

  • Yes @mgibsonbr, I ended up getting confused, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.