In Bash, # is used to comment the following. How do I make a comment on the Windows command line?
The command you're looking for is rem, short for "remark".
There is also a shorthand version :: that some people use, and this sort of looks like # if you squint a bit and look at it sideways. I originally preferred that variant since I'm a bash-aholic and I'm still trying to forget the painful days of BASIC :-)
Unfortunately, there are situations where :: stuffs up the command line processor (such as within complex if or for statements) so I generally use rem nowadays. In any case, it's a hack, suborning the label infrastructure to make it look like a comment when it really isn't. Labels are really literally labeled blocks of commands - used as jump targets for goto or callable subroutines with call. For example, this will produce an error ) was unexpected at this time, because it expects a command:
if 1==1 (
:: comment line 1
echo 1 equals 1
:: comment line 2
)
The same with rem instead of :: would work.
You should also keep in mind that rem is a command, so you can't just bang it at the end of a line like the # in bash. It has to go where a command would go. For example, the first line below outputs all hello rem a comment but the second outputs the single word hello:
echo hello rem a comment.
echo hello& rem a comment.
The second is two separate commands separated by &, and with no spaces before the & because echo will output those as well. That's not necessarily important for screen output but, if you're redirecting to a file, it may:
echo hello >file - includes the space.
echo hello>file - no space.