← 返回命令列表

Linux command

false 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Return failure status

false

Use in conditional

if false; then echo "never"; fi

Chain with or

false || echo "false returned failure"

Infinite loop idiom

while false; do :; done

说明

false does nothing and returns a failure exit status (1). It's the counterpart to true and is used in shell scripts for flow control, testing, and as a placeholder. The command takes no operands and always exits with status 1, indicating failure. This makes it useful in conditional statements, loops that should never execute, and testing error handling. false is a POSIX-standard command and shell builtin, providing a guaranteed failure exit status.

参数

--help
Display help information.
--version
Display version information.

FAQ

What is the false command used for?

false does nothing and returns a failure exit status (1). It's the counterpart to true and is used in shell scripts for flow control, testing, and as a placeholder. The command takes no operands and always exits with status 1, indicating failure. This makes it useful in conditional statements, loops that should never execute, and testing error handling. false is a POSIX-standard command and shell builtin, providing a guaranteed failure exit status.

How do I run a basic false example?

Run `false` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --help do in false?

Display help information.