# in shell scripts doesn't represent a beginning of a comment if it's not at the beginning of a word:
echo hello #world # this prints "hello"; the "#world" is a comment echo hello#world # this prints "hello#world"
#world is highlighted as a comment in both cases.
bash manpage (but this behavior is also present in other shell interpreters such as
[...] a word beginning with # causes that word and all remaining characters on that line to be ignored.
This is a bit tricky because in some cases such as
echo hello&#world, the
& marks the end of the command and thus
# is considered to be at the beginning of a word, so it's not as easy as checking if the char before the
# is a whitespace char.