In Bash and the Korn shell (Emacs mode) Esc-# is like putting a # at the beginning and pressing Enter:
Example:
$ find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl
(Esc- #) ;
$ #find /{,usr/}{,s}bin/ -type f -ls | awk '$3~/^...s/' | nl
$ _
Works inNotes
1: In some terminals, Alt+whatever as a chord is another way of sending Esc followed by whatever
2: # means whatever you need to press to get a '#' so you might have to press Esc then Shift+3 or Alt+Shift+3
(thank you @vi)
Customization
In Bash, you can control the prefix by adding a line like this to .inputrc:
set comment-begin "## "
(The quotation marks are only necessary if you have leading or trailing blanks)
You can also set another binding and unbind the Korn shell.default Esc-#:
"\e'": insert-comment
"\e#": nop
https://www.gnu.org/software/bash/manual/html_node/Readline-Init-File-Syntax.html