In bash GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu) or any stable one,
You can use #
or :
to comment
What's the difference between these 2 and usefulness?
I noticed #
comment makes the whole line a comment, while :
scope/effect is only until it reaches the first \n
or ;
character (in a given line).
[gigauser@someserver ~]$ # this is a # comment; echo this will not print
[gigauser@someserver ~]$ : this is a : comment; echo this will print
this will print
In the following code, why the last 2 comments didn't work as expected to treat them as a comment then (albeit ::
works if it comes after a :
?
[gigauser@someserver ~]$ #
[gigauser@someserver ~]$ ##
[gigauser@someserver ~]$ ####
[gigauser@someserver ~]$ ####
[gigauser@someserver ~]$ : : : : : : : : : :
[gigauser@someserver ~]$ #
[gigauser@someserver ~]$ # # #
[gigauser@someserver ~]$ ####
[gigauser@someserver ~]$
[gigauser@someserver ~]$ :
[gigauser@someserver ~]$ : :
[gigauser@someserver ~]$ : : : : : : : : : : : : ::::::::
[gigauser@someserver ~]$ : : :::::
[gigauser@someserver ~]$
[gigauser@someserver ~]$
[gigauser@someserver ~]$ ::
-bash: ::: command not found
[gigauser@someserver ~]$ :::::
-bash: :::::: command not found
[gigauser@someserver ~]$