Skip navigation

Terminal Question - Volumes

523 Views 5 Replies Latest reply: Mar 18, 2012 5:51 PM by jsd2 RSS
grnfrog55 Level 1 Level 1 (0 points)
Currently Being Moderated
Mar 18, 2012 2:19 PM

When I have mounted volumes for connecting to the c$ on my other windows machines.. they have the same volume names. My question is how do you navigate into each if they are named the same?   "c$"



I did a cd /volumes, and then a "ls" command


it displays :


"Macintosh HD           MobileBackups           C$           C$-1


so I type "cd c$" i can list all drives... I try "cd c$-1" and I get an error.. "-bash: cd: chimBH1: No such file or directory"



How do you differientiate between the two c$ volumes?





  • jsd2 Level 5 Level 5 (6,200 points)
    Currently Being Moderated
    Mar 18, 2012 3:12 PM (in response to grnfrog55)


    cd C$\-1

  • BobHarris Level 6 Level 6 (12,505 points)
    Currently Being Moderated
    Mar 18, 2012 4:10 PM (in response to grnfrog55)

    It is the $ that is causing problems.  Protect that $


    cd 'C$-1'




    cd C\$-1


    -OR- use a wildcard


    cd C*-1

    cd C?-1


    If you are going to be messing about using Terminal, you could always just use the mount command and specify your own mount point for each unique volume and avoid the C$ madness.

  • jsd2 Level 5 Level 5 (6,200 points)
    Currently Being Moderated
    Mar 18, 2012 5:06 PM (in response to BobHarris)


    Before posting my suggestion of cd C$\-1, I had tested it on a folder and it seemed to work there. Could you please explain why?


    For the test, I created folders named C$ and C$-1 in an empty USB flash drive, and then listed them:


    2010-Computer:~ t$

    2010-Computer:~ t$ cd /Volumes/USB2

    2010-Computer:USB2 t$ ls

    C$    C$-1


    I then tried to cd directly into C$, and that worked OK:


    2010-Computer:USB2 t$ cd C$

    2010-Computer:C$ t$


    After going back to the USB drive directory, I got the same error as the OP when I tried to cd into C$-1 directly:

    2010-Computer:C$ t$ cd /Volumes/USB2


    2010-Computer:USB2 t$ cd C$-1

    -bash: cd: ChimBH1: No such file or directory


    But I could cd into C$-1 by escaping the hyphen rather than the dollar:

    2010-Computer:USB2 t$ cd C$\-1

    2010-Computer:C$-1 t$


    Some questions:

    Why did this work?

    Why did cd C$ successfully enter the first folder - the $ was not escaped there.

    And where did "ChimBH1" come from in the error message above?


    Thanks much-


  • BobHarris Level 6 Level 6 (12,505 points)
    Currently Being Moderated
    Mar 18, 2012 5:39 PM (in response to jsd2)

    At the shell level, there is nothing magical about - (dash).

    But $ is the shells variable substitution operator.  Using single quotes around string with the $ or a backslash before the $ will disable the magical properties of the $


    I can only assume that if $ is not followed by a valid variable name it is ignored, but $- is a valid substitution, so $\- would no longer have a valid variable name following $.   And of course C$ has nothing following it, so again the $ is ignored.


    I cannot find any explicitly stated in the 'man bash' page, but a lot of things are not stated in the bash man page.  And I know that not all shells will honor the C$\-1 syntax, so 'C$-1' or C\$-1 is a safer approach to $ protection when it is in a file name.


    The himBH came from


         echo $-


    and C...1 where before and after $-

  • jsd2 Level 5 Level 5 (6,200 points)
    Currently Being Moderated
    Mar 18, 2012 5:51 PM (in response to BobHarris)

    Thanks again, much appreciated.


More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.