bash function parameters code example
Example 1: bash function
function hello {
echo Hello
}
hello
function e {
echo $1 # $1 is the first argument
}
e Hello
Example 2: bash function arguments
#!/usr/bin/env sh
foo 1 # this will fail because foo has not been declared yet.
foo() {
echo "Parameter #1 is $1"
}
foo 2 # this will work.
Example 3: function in bash
#FIRST METHOD
Hello () {
echo 'Hello Wordl'
}
Hello
#SECOND METHOD
function Hello {
echo 'Hello Wordl'
}
Hello