
nameref | 673
Bash and Korn
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
contain spaces or other special characters. The (( )) form does the
quoting for you. For more information and examples, see “Arith-
metic Expressions,” earlier in this chapter. See also expr in
Chapter 3.
Examples
Each of these examples adds 1 to variable i:
i=`expr $i + 1` All Bourne shells
let i=i+1 Bash, ksh
let "i = i + 1"
(( i = i + 1 ))
(( i += 1 ))
(( i++ )) Bash, ksh93
local
local [options] [name[=value]]
Bash only. Declares local variables for use inside functions. The
options are the same as those accepted by declare; see declare for
the full list. It is an error to use local outside a function body.
login
login [user]
Korn shell only. The shell does an execve(2) of the standard login
program, allowing you to replace one login session with another,
without having to logout first.
logout
logout
Bash only. Exit a login shell. The command fails if the current shell
is not a login shell.
name()
name ( ) { commands; }
Define name as a function. POSIX syntax. The function definition
can be written on one line or across many. Bash and the Korn shell
provide the function keyword, alternate forms that work similarly.
See the “Functions” section, earlier in the chapter.
Example
$ count ( ) {
> ls | wc -l
> }
When issued at the command line, count now displays the number
of files ...