Sharing the data with many functions

We can create variables that may contain strings or numerical values. These global variables can be accessed by all the functions inside a script.

A simple script called with functions is as follows:

# We will define variable temp for sharing data with function 
  echo "removing file $temp..." 

Test the script as follows:

    $ chmod +x
    $ ./

This should produce the following output:

    removing file /temp/filename...

Get Learning Linux Shell Scripting - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.