Why do I have double slash here?

5,090

Solution 1

which searches your PATH. It happens that mycommand is found in a $PATH entry with a trailing slash: /home/t/program_files/document/other edits/. which concatenates the directory, a / as separator, and the command name to build the filename to check; when the directory has a trailing slash, this results in two slashes.

Multiple slashes are equivalent to a single one, so this is completely inoccuous.

P.S. Why not use "which"? What to use then?

Solution 2

Thats because you have put a trailing forward slash (/) while adding the location /home/t/program_files/document/other edits in $PATH.

You might have used:

PATH=$PATH:/home/t/program_files/document/other\ edits/

You need to use to get rid of trailing /:

PATH=$PATH:/home/t/program_files/document/other\ edits

Although this is not that much of a problem AFAIK as shell will treat // as /.

Share:
5,090

Related videos on Youtube

Tim
Author by

Tim

Elitists are oppressive, anti-intellectual, ultra-conservative, and cancerous to the society, environment, and humanity. Please help make Stack Exchange a better place. Expose elite supremacy, elitist brutality, and moderation injustice to https://stackoverflow.com/contact (complicit community managers), in comments, to meta, outside Stack Exchange, and by legal actions. Push back and don't let them normalize their behaviors. Changes always happen from the bottom up. Thank you very much! Just a curious self learner. Almost always upvote replies. Thanks for enlightenment! Meanwhile, Corruption and abuses have been rampantly coming from elitists. Supportive comments have been removed and attacks are kept to control the direction of discourse. Outright vicious comments have been removed only to conceal atrocities. Systematic discrimination has been made into policies. Countless users have been harassed, persecuted, and suffocated. Q&A sites are for everyone to learn and grow, not for elitists to indulge abusive oppression, and cover up for each other. https://softwareengineering.stackexchange.com/posts/419086/revisions https://math.meta.stackexchange.com/q/32539/ (https://i.stack.imgur.com/4knYh.png) and https://math.meta.stackexchange.com/q/32548/ (https://i.stack.imgur.com/9gaZ2.png) https://meta.stackexchange.com/posts/353417/timeline (The moderators defended continuous harassment comments showing no reading and understanding of my post) https://cs.stackexchange.com/posts/125651/timeline (a PLT academic had trouble with the books I am reading and disparaged my self learning posts, and a moderator with long abusive history added more insults.) https://stackoverflow.com/posts/61679659/revisions (homework libels) Much more that have happened.

Updated on September 18, 2022

Comments

  • Tim
    Tim almost 2 years
    $ which mycommand
    /home/t/program_files/document/other edits//mycommand
    

    Why do I have double slash // here?

    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' over 9 years
      Because slash existed several centuries earlier than backslash.
    • Tim
      Tim over 9 years
      How do you remember which is called which?
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' over 9 years
      The one that's used in general typography is the slash. The one that's only used in a few weird computer contexts is the backslash.
    • Janis
      Janis over 9 years
      Tim, by the same mental process that lets me distinguish A from B.
    • Jacob Matias
      Jacob Matias over 9 years
      THe easiest way to remember which is which is to start at the bottom of the slash and follow it to the top, if to goes back its a backslash and if it goes forward it is a forward slash aka slash. I guess this only works for left to right readers but you get the idea.
    • Cole Tobin
      Cole Tobin over 9 years
      When I was learning, I'd look at it like an arrow (tip at top). A backslash points backwards while a forwardslash points forward
    • androidism
      androidism over 9 years
      @Dylan besides L-R orientation, I think it's safe to say the majority reads from a top-to-bottom orientation, tracing from the bottom of the slash upwards is a bit... (just saying, haha)
    • Jacob Matias
      Jacob Matias over 9 years
      @h.j.k. Are you saying I was being presumptions? I am missing your point, sorry if I am being dense.
    • androidism
      androidism over 9 years
      @Dylan nah, personal anecdote: I used to remember it the same way as you describe, but I start from the top and got both terms mixed up! Now I simply remember / as slash, and therefore the other one is the backslash. Cheers. :)
    • androidism
      androidism over 9 years
      It's a useful mnemonic, but just have to remember to start from the bottom, else confusion ensues heheh...
  • Tim
    Tim over 9 years
    Is putting a trailing forward slash (/) in $PATH bad?
  • heemayl
    heemayl over 9 years
    @Tim: Check my edits..shell will treat // as / so wont be a problem