The dot character (.)

The dot command is a shell builtin, and it has the same function of the source; when executed into the shell, it executes a file. And if it is used inside a script, it loads the referenced file content:

zarrelli:~$ comment.shbash: comment.sh: command not foundzarrelli:~$ . comment.sh* 1 2 3 comment.sh menu.sh test.txt# I am a comment but you can see me

As we can see from this example, the first try was not successful because comment.sh is not in the search path; but the second time, we were successful since the dot command executed the script. Now, let's see how to include some code from an external file into a script. Let's start writing the external file that we will source from the following code:

zarrelli:~$ cat ...

Get Mastering Bash now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.