function — Shell Built-in Command to Define a Shell Function

Synopsis

ksh
function identifier {list;} 
identifier() {list;} 

Description

Korn Shell

function defines a function that is referenced by identifier . The body of the function is the list of commands between the curly braces ({}).

Alternatively, you can define a function by omitting the function keyword and appending the identifier with a set of enclosed parentheses.

Examples

The following example creates a function called status() that returns the name of your current working directory and then lists it.

$ status() { cd $*; pwd;ls; } 
$ 
$ functions 
function status 
{
cd $*; pwd;ls; } 
$ 
$ status /home 
/home 
TT_DB       bill        lost+found 
$ 

The following example creates a function called ...

Get Solaris™ 7 Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.