$0 is a special parameter in Bash…
As explained in this comment on that answer you link to, echo $0
simply shows you the name of the currently running process:
$0 is the name of the running process. If you use it inside of a shell then it will return the name of the shell. If you use it inside of a script, it will be the name of the script.
More details can be found here on this other site:
$0 is one of the Bash special parameters. It can only be referenced as follows (just an example as there are various ways to reference and use $0 while scripting).
So just create a Bash script like this. First open up a file for writing called test.sh
with Nano like this:
nano test.sh
Then put these contents into that file:
#!/bin/bash
echo $0
Then hit Ctrl+X, save the file. Now make the script executable like this:
chmod 700 test.sh
Now run it like this:
./test.sh
And the output would be:
./test.sh
So for the purposes you describe echo $0
won’t really work.