Builtins are commands that are part of (built into) the shell. When you give a simple filename as a command, the shell first checks whether it is the name of a builtin. If it is, the shell executes it as part of the calling process; the shell does not fork a new process to execute the builtin. The shell does not need to search the directory structure for builtin programs because they are immediately available to the shell.
If the simple filename you give as a command is not a builtin, the shell searches the directory structure for the program you want, using the PATH variable as a guide. When it finds the program the shell forks a new process to execute the program.
Table 9-10. tcsh builtins
Builtin | Function |
---|
% job | A synonym for the fg builtin. The job is the job number of the job you want to bring to the foreground (page 273). |
% job & | A synonym for the bg builtin. The job is the number of the job you want to put in the background (page 274). |
@ | Similar to the set builtin but evaluates numeric expressions. Refer to "Numeric Variables" on page 355. |
alias | Creates and displays aliases; bash uses a different syntax than tcsh. Refer to "Aliases" on page 344. |
alloc | Displays a report of the amount of free and used memory. |
bg | Moves a suspended job into the background (page 274). |
bindkey | Controls the mapping of keys to the tcsh command line editor commands. |
bindkey | Without any arguments, bindkey lists all key bindings (page 350). |
bindkeyl | Lists all available editor commands along with a short description of each. |
bindkeye | Puts the command line editor in emacs mode (page 350). |
bindkeyv | Puts the command line editor in vi(m) mode (page 350). |
bindkey key command | Attaches the editor command command to the key key. |
bindkeyb key command | Similar to the previous form but allows you to specify control keys by using the form Cx (where x is the character you type while you press the CONTROL key), specify meta key sequences as Mx (on most keyboards used with Mac OS X, the OPTION key is the meta key, but you have to set an option in the Terminal utility to use it; see page 31), and specify function keys as F-x. |
bindkeyc key command | Binds the key key to the command command. Here the command is not an editor command but either a shell builtin or an executable program. |
bindkeys key string | Whenever you type key, string is substituted. |
builtins | Displays a list of all builtins. |
cd or chdir | Changes working directories (page 82). |
dirs | Displays the directory stack (page 275). |
echo | Displays its arguments. You can prevent echo from displaying a RETURN at the end of a line by using the n option (see "Reading User Input" on page 358) or by using a trailing \c (see "read: Accepts User Input" on page 571). The echo builtin is similar to the echo utility (page 720). |
eval | Scans and evaluates the command line. When you put eval in front of a command, the command is scanned twice by the shell before it is executed. This feature is useful with a command that is generated by command or variable substitution. Because of the order in which the shell processes a command line, it is sometimes necessary to repeat the scan to achieve the desired result. See an example of the use of eval on page 316. |
exec | Overlays the program currently being executed with another program in the same shell. The original program is lost. Refer to "exec: Executes a Command" on page 574 for more information; also refer to source (page 376). |
exit | Exits from a TC Shell. When you follow it with a numeric argument, tcsh returns that number as the exit status (page 564). |
fg | Moves a job into the foreground (page 272). |
filetest | Takes one of the file inquiry operators followed by one or more filenames and applies the operator to each filename (page 367). Returns the results as a space-separated list. |
glob | Like echo, but does not display SPACEs between its arguments and does not follow its display with a NEWLINE. |
hashstat | Reports on the efficiency of tcsh's hash mechanism. The hash mechanism speeds the process of searching through the directories in your search path. See also rehash (page 376) and unhash (page 377). |
history | Displays a list of recent commands (page 342). |
jobs | Displays a list of jobs (suspended commands and those running in the background). |
kill | Terminates a job or process (page 580). |
limit | Limits the computer resources that the current process and any processes it creates can use. You can put limits on the number of seconds of CPU time the process can use, the size of files that the process can create, and so forth. |
log | Immediately produces the report that the watch shell variable (page 362) would normally produce every 10 minutes. |
login | Logs in a user. Can be followed by a username. |
logout | Ends a session if you are using your original (login) shell. |
lsF | Similar to lsF but faster. (This builtin is the characters lsF without any SPACEs.) |
nice | Lowers the processing priority of a command or a shell. It is useful if you want to run a command that makes large demands on the system and you do not need the output right away. If you are Superuser, you can use nice to raise the priority of a command. Refer to page 794 for more information on the nice builtin and the nice utility, which is available from bash. |
nohup | Allows you to log out without terminating processes running in the background. Some systems are set up to do this automatically. Refer to page 798 for information on the nohup builtin and the nohup utility, which is available from bash. |
notify | Causes the shell to notify you immediately when the status of one of your jobs changes (page 272). |
onintr | Controls what action an interrupt causes within a script (page 367). See "trap: Catches a Signal" on page 577 for information on the equivalent command in bash. |
popd | Removes a directory from the directory stack (page 275). |
printenv | Displays all environment variable names and values. |
pushd | Changes the working directory and places the new directory at the top of the directory stack (page 275). |
rehash | Re-creates the internal tables used by the hash mechanism. Whenever a new instance of tcsh is invoked, the hash mechanism creates a sorted list of all available commands based on the value of path. After you add a command to a directory in path, use rehash to re-create the sorted list of commands. If you do not, tcsh may not be able to find the new command. Also refer to hashstat (page 375) and unhash (page 377). |
repeat | Takes two argumentsa count and simple command (no pipes or lists of commands)and repeats the command the number of times specified by the count. |
sched | Executes a command at a specified time. For example, the following command causes the shell to print the message Dental appointment. at 10 AM: tcsh $ sched 10:00 echo "Dental appointment." Without any arguments, sched prints the list of scheduled commands. When the time to execute a scheduled command arrives, tcsh executes the command just before it displays a prompt. |
set | Declares, initializes, and displays local variables (page 352). |
setenv | Declares, initializes, and displays environment variables (page 352). |
shift | Analogous to the bash shift builtin (page 567). Without an argument, shift promotes the indexes of the argv array. You can use it with an argument of an array name to perform the same operation on that array. |
source | Executes the shell script given as its argument: source does not fork another process. It is similar to the bash. (dot) builtin (page 261). The source builtin expects a TC Shell script so no leading #! is required in the script. The current shell executes source so that the script can contain commands, such as set, that affect the current shell. After you make changes to your .tcshrc or .login file, you can use source to execute it from the shell and thereby put the changes into effect without logging off and on. You can nest source builtins. |
stop | Stops a job or process that is running in the background. The stop builtin accepts multiple arguments. |
suspend | Stops the current shell and puts it in the background. It is similar to the suspend key, which stops jobs running in the foreground. |
time | Executes the command that you give it as an argument. It displays a summary of time-related information about the executed command, according to the time shell variable (page 361). Without an argument, time displays the times for the current shell and its children. |
umask | Identifies or changes the access permissions that are assigned to files you create (page 883). |
unalias | Removes an alias (page 344). |
unhash | Turns off the hash mechanism. See also hashstat (page 375) and rehash (page 376). |
unlimit | Removes limits (page 375) on the current process. |
unset | Removes a variable declaration (page 352). |
unsetenv | Removes an environment variable declaration (page 352). |
wait | Causes the shell to wait for all child processes to terminate. When you give a wait command in response to a shell prompt, tcsh does not display a prompt until all background processes have finished execution. If you interrupt it with the interrupt key, wait displays a list of outstanding processes before tcsh displays a prompt. |
where | When given the name of a command as an argument, locates all occurrences of the command and, for each, tells you whether it is an alias, a builtin, or an executable program in your path. |
which | Similar to where but reports on only the command that would be executed, not all occurrences. This builtin is much faster than the Mac OS X which utility and knows about aliases and builtins. |