Built-in Commands

Each shell also includes built-in commands for efficiency. Table 85 lists the built-in commands. The Bourne shell relies more on using external commands to do the work, and thus has the fewest built-in commands. The additional built-in commands for the Korn shell are shown by (K) following the command name. The job control variant of the Bourne shell, jsh, has the same job control features as the Korn shell.

CAUTION

Do not use any of the built-in commands as names for shell scripts. If you use one of the built-in commands as a shell script name, the shell will execute the built-in command instead of running the script.


Table 85. Shell Built-In Commands
Purpose Bourne or Korn Shell C Shell
Null command. : :
Create a command name alias. alias (K) alias
Run current command in background. bg (K) bg
Exit enclosing for or while loop. break break
Break out of a switch. N/A breaksw
Change directory. cd cd
Continue next iteration of for or while loop. continue continue
Default case in switch. N/A default
Print directory stack. N/A dirs
Write arguments on standard output. echo, print (K) echo
Evaluate and execute arguments. eval eval
Execute the arguments. exec exec
Return or set shell variables. set @
Exit shell program. exit exit
Create an environment variable. export setenv
Bring a command into foreground. fg (K) fg
Execute foreach loop. for foreach
Perform file-name expansion. N/A glob
Go to label within shell program. N/A goto
Display history list. fc -l (K) history
if-then-else decision. if if
List active jobs. jobs (K) jobs
Send a signal. kill kill
Set limits for a job's resource use. ulimit limit
Terminate login shell and invoke login. N/A login
Terminate a login shell. N/A logout
Change to a new user group. newgrp (K) N/A
Change priority of a command. N/A nice
Ignore hang up. N/A nohup
Notify user when job status changes. N/A notify
Control shell processing on receipt of a signal. trap onintr
Pop the directory stack. N/A popd
Push a directory onto the stack. N/A pushd
Read a line from standard input. read $<
Change a variable to read-only. readonly N/A
Repeat a command n times. N/A repeat
Set shell environment variables. = setenv
Set a local C shell variable. N/A set
Shift positional parameters $* or $argv. shift shift
Read and execute a file. . (dot) source
Stop a background process. N/A stop
Stop the shell. suspend (K) suspend
Case statement. case ... esac switch ... endsw
Evaluate conditional expressions. Note that test is normally an external program except for the Korn shell. test

[ ]

[[ ]] (K)
N/A
Display execution times. times time
Set default security for creation of files and directories. umask umask
Discard aliases. unalias (K) unalias
Remove limitations on resources. ulimit unlimit
Unset a variable. unset unset
Unset an environment variable. unset unsetenv
until loop. until N/A
Wait for background process to complete. wait N/A
while loop. while while

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.101.72