unix4artists/bash/functions.sh

26 lines
610 B
Bash
Raw Normal View History

2021-05-08 16:53:26 +00:00
#!/bin/bash -e
#####################################################
#
# Functions can be defined using the "name () {}"
# notation where the code is contained within the
# brackets. Functions receive arguments the same way
# a script does, using the "$#" notation.
#
#####################################################
myFunction () {
if [ "${1}" != "" ]; then
echo "Your first argument is \"${1}\""
else
echo "Called myFunction with no arguments"
fi
}
# Invoke your function as if it were any other command
# or application located in your $PATH.
myFunction
sleep 2
myFunction "First argument"