Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

The : (colon) operator is a POSIX-compliant shell builtin command that functions as a null utility. It performs no operation, produces no output, and strictly returns a zero exit status (0), representing logical truth or success.
: [arguments]

Execution Mechanics

Exit Status The command unconditionally terminates with an exit code of 0. In terms of return value, it is functionally identical to the true builtin.
:
echo $? # Outputs: 0
Argument Parsing and Expansion Although the : command discards all arguments passed to it, the shell’s parser still processes the command line prior to invoking the builtin. Consequently, any parameter expansion, command substitution, or arithmetic expansion provided as an argument to : is fully evaluated by the shell.

# The shell evaluates the arithmetic expansion before passing the result to ':'
: $((X = 5 + 5))
echo $X # Outputs: 10


# The shell executes the command substitution before passing the result to ':'
: $(touch /tmp/side_effect.txt)


# The shell performs parameter expansion (assigning a default value)
: ${VAR:=default_value}
I/O Redirection Because : is a valid command, the shell processes standard input and output redirections applied to it. The command itself writes nothing to standard output, meaning redirection operations are executed by the shell but receive an empty byte stream from the utility.

# The shell opens and truncates the file, then ':' writes nothing to it
: > output.log
Builtin Precedence As a special builtin, : executes directly within the current shell environment. It does not fork a subshell or invoke an external binary, making its execution overhead negligible.
Master Bash with Deep Grasping Methodology!Learn More