UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: [[  ]]Chapter 4
The Bourne Shell and Korn Shell
Next: Reference: alias
 

name()

name () { commands; }

Define name as a function. Syntax can be written on one line or across many. Since the Bourne shell has no aliasing capability, simple functions can serve as aliases. The Korn shell provides the function keyword, an alternate form that works the same way.

There are semantic differences that should be kept in mind:

Example


$ count () {
> ls | wc -l
> }

When issued at the command line, count now displays the number of files in the current directory.


Previous: Reference: [[  ]]UNIX in a Nutshell: System V EditionNext: Reference: alias
Reference: [[ ]]Book IndexReference: alias

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System