Functions in Bash
A function that can also be referred to as a subroutine or procedure is a block of code used for specific tasks. The function also has a property called re-usability. Bash script also provides functions.
Syntax:
1. Bash – Create Function Example
Create your first function in shell script showing the output “Hello World!”. Create a shell script “script.sh” using the following code.
Let execute script
2. Bash – Function with Argument
Passing an argument to functions is similar to passing an argument to a command from the shell. Functions receive arguments to $1,$2… etc. Create a shell script using the following code.
Let’s execute the script with the bash shell.
0 Comments
CAN FEEDBACK
Emoji