Name

function

Synopsis

function name { commands; }
function name () { commands; }

Define name as a shell function. See the description of function semantics in the earlier section Functions.

Example

Define a function to count files.

$ function fcount {
>    ls | wc -l
> }

Get bash Quick 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.