November 2015
Beginner
282 pages
5h 5m
English
Similar to other programming languages, function is a way to write a set of actions once and use it multiple times. It makes the code modular and reusable.
The syntax of writing a function is as follows:
function function_name { # Common set of action to be done }
Here, function is a keyword to specify a function and function_name is the name of the function; we can also define a function in the following ways:
function_name() { # Common set of action to be done }
The actions written within curly braces are executed whenever a particular function is invoked.
Consider the following shell script that defines the my_func()function:
#!/bin/bash # Filename: function_call.sh # Description: ...
Read now
Unlock full access