Shell Built-Ins

Built-ins are used in shell programs to make decisions and to add intelligence to the task to be performed. Built-ins for the Bourne shell are listed in Tables 3.6 and 3.7. More information on the built-ins described in Table 3.6 is available in the Solaris online manual pages. The shell conditionals listed in Table 3.7 are described in this chapter. Each shell has its own set of built-ins, with the Bourne shell having the fewest. For this reason, it is the smallest and fastest of the three shells.

Table 3.6. Bourne Shell Built-Ins
Built-In Description
break Exits a for or while loop
continue Continues the next iteration of a for or while loop
echo Writes arguments on standard output
eval Evaluates and executes arguments
exec Executes a program. Executes in place of the current process so that exec does not create a new process
exit Exits the shell program
export Creates a global variable
priv Sets or displays privileges
read Reads a line from standard input
readonly Changes a variable to read-only
set Sets shell options
test Evaluates conditional expressions
times Displays execution times
trap Manages execution signals
umask Sets default security for files and directories
unset Unsets a local variable
wait Waits for a background process to complete

Table 3.7. Bourne Shell Conditionals
Conditional Description
if-then-else-fi Tests a condition and selects an action based on the results of the test
case-esac Selects an action based on the value of the variable
for-do-done Repeats a sequence of commands until a predetermined condition is met
while-do-done Repeats a sequence of commands until a test condition is no longer true
until-do-done Repeats a sequence of commands until a test condition results in a successful status

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

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