DEV Community

DaniAcu
DaniAcu

Posted on

3

Answer Dev Questions #1: Demystifying Special Characters in Paths

Recently, while engaging in a online discussion, a question caught my attention.

Sometimes i see symbols like “@“ or “*” or “” or “^” or “~”
And I don't know what are they used in ..?!

I wait some time, but I saw that anyone answer the question, I just saw one intention to doit that was a link of a blog post that not track the entire question. So I take the time to answer it, and after doing it I just ask to myself: Why do not create post of this answer?

So here I am, maybe for expert it sounds easy-peasy or like a piece of cake but for the most beginers that try to find some guide in the masive world of things it could be helpful.

All this symbols in the question are for different things.

@

Let start with the at symbol (@). As the question was asked about a js file, so I could say that in JS projects is used to have a convenient way to access to root folder of your app.
Instead of doing ../../../../../../../../../, accesing from the root could be shorted but the most important benefit is that alias is the same for every file. So moving file dont need update imports.
For more information check the rollup alias plugin

*, **, ^

The asterisks (* or **), carret(^), is more a OS thing or to be specific is part of glob (https://en.wikipedia.org/wiki/Glob_(programming)).
In general it means the following:

  • * (any file)
  • ** (any folder)
  • ^ (exclude this, but I think that you need some extension of glob or something like that. check this discussion about it)

~

The tilde symbol (~) is for user directory. In linux you could go to your user directory using "cd ~" any time. Some any path written with than means that is searching the path starting form user directory, it an alias already provided by the OS. Check this link

I hope this explanation was helpful to you, because I really enjoy wrinting this answer.

See you in the next one.

Here my links.
Twitter
Github

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay