Search code examples
terminalmacos-high-sierra

mac high sierra directory path in terminal


I am doing something very simple in Scala. I wrote a short program and have it saved in file ScalaTutorial.scala which is in my downloads directory.

Using the Mac High Sierra terminal, I cam trying to compile my program. at the prompt, I have:

scalac /Macintosh\ HD/Users/myName/Downloads/ScalaTutorial.scala

However, I get an error:

error: source file '/Macintosh HD/Users/myName/Downloads/ScalaTutorial.scala' could not be found.

While I am obviously referring to the file location incorrectly, it is not clear to me how I should refer to the file location. I have tried with and without the leading '/', I have tried enclosing the location in quotes, and I have not seen an example surfing the web


Solution

  • You should just need:

    scalac /Users/myName/Downloads/ScalaTutorial.scala
    

    The Macintosh HD volume would normally be mounted at the root, so you just need / to access it.

    It would also be accessible under /Volumes/Macintosh\ HD/, but / is more-direct and will work if you change the volume name.

    Simpler still, you can most-likely use ~/ to get to your home directory:

    scalac ~/Downloads/ScalaTutorial.scala