HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

function — Define a function. More information: <https://www.gnu.org/software/bash/manual/bash.html#Shell-Funct

Submitted by: @import:tldr-pages··
0
Viewed 0 times
httpscommandfunctiondefinecliinformationmore

Problem

How to use the function command: Define a function. More information: <https://www.gnu.org/software/bash/manual/bash.html#Shell-Functions>.

Solution

function — Define a function. More information: <https://www.gnu.org/software/bash/manual/bash.html#Shell-Functions>.

Define a function with the specified name:
function {{func_name}} { {{echo "Function contents here"}}; }


Run a function named func_name:
func_name


Define a function without the function keyword:
{{func_name}}() { {{echo "Function contents here"}}; }


Display help:
help function

Code Snippets

Define a function with the specified name

function {{func_name}} { {{echo "Function contents here"}}; }

Run a function named `func_name`

func_name

Define a function without the `function` keyword

{{func_name}}() { {{echo "Function contents here"}}; }

Display help

help function

Context

tldr-pages: common/function

Revisions (0)

No revisions yet.