Here the tilde (~) character is being used as a shortcut for /Users/oliver. bash_profile file in your home directory and adding the lines: #!/bin/sh export PATH=$PATH:~/bin
This can be does easily by either creating or editing the existing. For example, if you have a "bin" directory in your home directory for regularly used shell scripts of other programs it may be wise to alter your executable search path. If you are commonly putting programs in a place on your hard disk that you wish to run without having to qualify their names. To determine which directory you are currently in use the pwd command. The current directory you are in is the period character followed by a slash. Similarly if I am in the same directory as MyProgram I need to use a "current directory" relative path. Or say I was in the directory /Users/oliver/MyProject2 and I wanted to execute /Users/oliver/MyProject/MyProgram I can use a relative path like this, to execute it:
For example, if MyProgram was in the directory /Users/oliver/MyProject I and I was in my home directory I can qualify the executable name like this, and have it execute: If you are in a location that is near the program you wished to execute you can qualify the name with a partial path. So say I had an executable called MyProgram in my home directory on Mac OS X I can fully qualify it like so: To run any other command that is not in the executable search path requires that you qualify the path to the executable. This runs /bin/cat and displays mytextfile.txt to the terminal. So any executable in the listed directories can by run just by typing in their name.
#Mac run unix executable file from terminal mac os x
On Mac OS X (by default) this will display the following colon separated search path: You can display this path in the terminal with this command: All application execution in a Unix (Linux, Mac OS X, AIX, etc.) environment depends on the executable search path.