| 1 | #!/bin/bash |
| 2 | # Note that this example must be invoked with bash, i.e., bash ex38.sh |
| 3 | #+ not sh ex38.sh ! |
| 4 | |
| 5 | . data-file # Load a data file. |
| 6 | # Same effect as "source data-file", but more portable. |
| 7 | |
| 8 | # The file "data-file" must be present in current working directory, |
| 9 | #+ since it is referred to by its basename. |
| 10 | |
| 11 | # Now, let's reference some data from that file. |
| 12 | |
| 13 | echo "variable1 (from data-file) = $variable1" |
| 14 | echo "variable3 (from data-file) = $variable3" |
| 15 | |
| 16 | let "sum = $variable2 + $variable4" |
| 17 | echo "Sum of variable2 + variable4 (from data-file) = $sum" |
| 18 | echo "message1 (from data-file) is \"$message1\"" |
| 19 | # Escaped quotes |
| 20 | echo "message2 (from data-file) is \"$message2\"" |
| 21 | |
| 22 | print_message This is the message-print function in the data-file. |
| 23 | |
| 24 | |
| 25 | exit $? |