Bourne shell commands
You can issue commands in the Bourne shell.
When you issue a command in the Bourne shell, it first evaluates
the command and makes all indicated substitutions. It then runs the
command provided that:
- The command name is a Bourne shell special built-in command.
OR
- The command name matches the name of a defined function. If this is the case, the shell sets the positional parameters to the parameters of the function.
If the command name matches neither a built-in command nor the
name of a defined function and the command names an executable file
that is a compiled (binary) program, the shell (as parent)
creates a new (child) process that immediately runs the program.
If the file is marked executable but is not a compiled program, the
shell assumes that it is a shell procedure. In this case, the shell
creates another instance of itself (a subshell), to read the
file and execute the commands included in it. The shell also runs
a parenthesized command in a subshell. To the user, a compiled program
is run in exactly the same way as a shell procedure. The shell normally
searches for commands in file system directories in this order:
- /usr/bin
- /etc
- /usr/sbin
- /usr/ucb
- $HOME/bin
- /usr/bin/X11
- /sbin
- Current directory
The shell searches each directory, in turn, continuing with the
next directory if it fails to find the command.
Note: The PATH variable
determines the order in which the shell searches directories. You
can change the particular sequence of directories searched by resetting
the PATH variable.
If you give a specific path name when you run a command (for example, /usr/bin/sort), the shell does not search any directories other than the one you specify. If the command name contains a slash (/), the shell does not use the search path.
You can give a full path name that begins with the root directory
(such as /usr/bin/sort). You can also specify
a path name relative to the current directory. If you specify, for
example:
bin/myfile
the shell looks in the current
directory for a directory named bin and in that
directory for the file myfile.Note: The restricted
shell does not run commands containing a slash (
/
).The shell remembers the location in the search path of each executed command (to avoid unnecessary exec commands later). If it finds the command in a relative directory (one whose name does not begin with /), the shell must redetermine the command's location whenever the current directory changes. The shell forgets all remembered locations each time you change the PATH variable or run the hash -r command.