Functions in Linux Shell Scripting

Main use of functions is that we can  reuse the same code and we can call the same function many times.

We can write functions in shell scripts, using below syntax. To call the function, you can just use the name of the function as a command. Note that definition of the function should appear first in a bash file and then we can call the function. If you try to call the function before defining it, you will get an error saying “command not found”

f1 ()
echo “This is a simple function in Linux shell scripting”


You may also like...