LinuxCommandLibrary

true

Return a zero exit status (always true)

TLDR

Return a successful exit code

$ true
copy

Make a command always exit with 0
$ [command] || true
copy

SYNOPSIS

true

DESCRIPTION

true does nothing except return a successful (zero) exit status. It's used in shell scripts where a command is syntactically required but no action is needed, or to create infinite loops.

CAVEATS

Always returns exit code 0. The shell built-in may be faster than /bin/true.

COMMON USES

while true; do ...; done - Infinite loop
cmd || true - Ignore failure
: > file - Truncate file (: is similar)

SEE ALSO

false(1), :(1), test(1)

Copied to clipboard