unix path guide
|
url link:http://stackoverflow.com/questions/221185/how-to-run-c-c-in-a-unix-console-mac-terminal
You can display this path in the terminal with this command:
On MacOS X (by default) this will display the following colon separated search path:
So any executable in the listed directories can by run just by typing in their name. Eg:
This runs To run any other command that is not in the executable search path requires that you qualify the path to the executable. So say I had an executable called MyProgram in my home directory on MacOS X I can fully qualify it like so:
If you are in a location that is near the program you wished to execute you can qualify the name with a partial path. For example if
Or say I was in the directory
Similarly if I am in the same directory as
To determine which directory you are currently in use the If you are commonly putting programs in a place on your hard disk that you wish to run without having to qualify their names. For example if you have a "bin" directory in your home directory for regularly used shell scripts of other programs if may be wise to alter your executable search path. This can be does easily by either creating or editing the existing
Here the tilde (~) character is being used as a shortcut for /Users/oliver. Also note that the hash bang (#!) line needs to be the first line of the file (if it doesn't already exist). Note also that this technique requires that your login shell be bash (the default on MacOS X and most Linux distributions). Also note that if you want your programs installed in ~/bin to be used in preference to system executables your should reorder the export statement as follows:
|

浙公网安备 33010602011771号