How it works...

In step one, we created whoami.sh. It is similar to the whoami command, but different because we do not print the $USER variable, but rather argument 0 (arg0, as its typically known) or $0. In laymen's terms, we are printing out the name used to execute the code or script.

When we execute whoami.sh, it prints to the console:

$ bash whoami.sh I was ran as: whoami.sh

To create a symbolic soft link, we use ln with the -s flag (for symbolic mode). The ln command expects to be executed in this way: $ ln -s originalFileToBeLinkedTo newFileToLinkToOldFile.

As we can see in the following code, executing ghosts-there-be.sh runs the code in whoami.sh, but arg0 is ghosts-there-be.sh. Then, when the ls command is ran with the -l -a flags ...

Get Bash Cookbook 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.