Most of the time when you run a program through a graphic user interface, you double-click on an icon which is associated with the program file.
However, there are cases when you need to (or prefer to) run a program by typing its name into a command shell (the Terminal on Mac OS X). When you do so, the shell looks for a program file with that name, and if it finds one, runs it. The
PATH is a variable that tells the shell where to look.
On Unix systems, typically all program files, no matter what software package they originate from, are placed in a single directory,
/usr/bin. (This is not strictly true, as there is also
/usr/local/bin, etc. but that's not important now.) And the
PATH is initially set to
/usr/bin, so that when you want to run a program, no matter what directory you are in, if you type
fooprogram, the shell will immediately look for it in
/usr/bin, and if it finds it, run it. Without this capability, the shell would be limited to looking in the current directory (which means you'd always have to be in the program directory to run anything), or else every directory in the file system (which would take a long time).
It is possible to add multiple directories (separated by the : character) to the PATH variable so that it searches all of them in sequence. This is what your command
You've just installed a software package, which includes some program files, in
/Users/your_user/scala. Following the convention, the program files are in the
bin subdirectory. So in order to allow you to run those programs directly from the command shell, you need to add
/Users/your_user/scala/bin so that the shell looks in there as well. The
$PATH stands for the existing value of
PATH, so that if
PATH was originally
/usr/bin, it is now
/Users/your_user/scala/bin:/usr/bin. The order matters, so that if both
/usr/bin contain a program file named
scala_prog, it will run the first one.
export is a command which makes this new value of
PATH available any time you run a command shell after that.
It's possible that you, the user, won't actually run the scala program files from a command shell, but the scala package itself may need to do so from its own shell scripts. In such a case the shell script will try to run the program with just the program name, and will thus need to have the
PATH set properly, just like you would if typing it at the command shell prompt.