← 返回命令列表

Linux command

bash 命令

网络

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

常用示例

Run

bash [script.sh]

Execute

bash -c ["echo hello"]

Interactive

bash -l

Read

echo "ls -la" | bash

Debug

bash -x [script.sh]

Example

bash -n [script.sh]

说明

bash (Bourne Again SHell) is a Unix shell and command language interpreter. It's the default shell on most Linux distributions and macOS, providing command execution, scripting, job control, and extensive programming features. Bash is backward-compatible with the original Bourne shell (sh) while adding numerous improvements and modern features.

参数

-c _string_
Execute command from string
-l, --login
Login shell (sources profile files)
-i
Interactive mode
-x
Print commands before execution (debug mode)
-n
Syntax check only (no execution)
-e
Exit on first error
-u
Error on undefined variables
-v
Verbose mode (print input lines)
--noprofile
Don't read profile files
--norc
Don't read ~/.bashrc
--posix
Behave according to POSIX standard
-r, --restricted
Start a restricted shell
--version
Display bash version

FAQ

What is the bash command used for?

bash (Bourne Again SHell) is a Unix shell and command language interpreter. It's the default shell on most Linux distributions and macOS, providing command execution, scripting, job control, and extensive programming features. Bash is backward-compatible with the original Bourne shell (sh) while adding numerous improvements and modern features.

How do I run a basic bash example?

Run `bash [script.sh]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -c _string_ do in bash?

Execute command from string