The site you link to has very low quality
To answer your question up-front, the "trailing colon" has no special meaning to the shell, it is just part of an string to be printed on the screen.
However the code on the page has this flaws:
The most important issue that you should learn is "quote your expansions".
That is "Parameter Expansions" (variable), but also other expansions.
This is the main reason I am writing this. It is very bad to get into the habit of failing to quote expansions.
There is no mention of the shebang mechanism anywhere in the page. (it means to have a first line like #!/bin/bash or similar). Writing scripts without stating the type of shell meant to run them is a sure source of bugs and problems.
Line number 11 is missing the argument that is used to call the function. It should be something like:
else useron "$1" instead of
After those three clear mistakes, we can run the script:
As you can see, the string on line 10 is printed as is on the console.
The trailing colon
: does not mean anything to the shell, which becomes clear when the string is quoted as this:
then echo "testlogin: username"
In fact, IMO, It would be be even more explicit:
then echo "A parameter is needed, type something like 'testlogin: username'"
Now the execution of the script without an argument prints a helpful answer.
And writing an username also work:
$ testlogin joe
joe is not logged in
The script with the changes above is:
if ( who | grep "$1" > /dev/null)
then echo "$1 is logged in"
else echo "$1 is not logged in"
if test "$#" != "1"
then echo "Parameter missing, type something like 'testlogin: username'"
else useron "$1"
Now, for a second round of issues:
test external command has fallen in disuse on most shells.
It has been replaced by the fully equivalent
[ or by
[[ in more modern shells. The line used in the script:
if test "$#" != "1" should be replaced by:
if [ "$#" != "1" ]
Now we get to writing style. On modern times, it is more common to see the script written like this (but that is a matter of personal preference):
if ( who | grep "$1" > /dev/null); then
echo "$1 is logged in"
echo "$1 is not logged in"
if [ "$#" != "1" ]; then
echo "Parameter missing, type something like 'testlogin: username'"