An Introduction to the Command-Line (on Unix-like systems)

by Oliver; 2014

10. Single Line Comments

Anything prefaced with a # —that's pound-space—is a comment and will not be executed:
$ # This is a comment.
$ # If we put the pound sign in front of a command, it won't do anything:
$ # ls -hl
Suppose you write a line of code on the command line and decided you don't want to execute it. You have two choices. The first is pressing Cntrl-c, which serves as an "abort mission." The second is jumping to the beginning of the line (Cntrl-a) and adding the pound character. This has an advantage over the first method that the line will be saved in bash history (discussed below) and can thus be retrieved and modified later.

In a script, pound-special-character (like #!) is sometimes interpreted (see below), so take note and include a space after # to be safe.

<PREV   NEXT>