命令中的 $(&符号)是什么意思?

what means $ (ampersand) in a command?

此命令开头的 $ 是什么意思?

$ bash testscript

如果我 运行 带 $ 的命令,结果是“找不到命令”

what means the $ at the begin of this command?

$ bash testscript

代表the prompt.

没有实际意义,只是提示符的“header”,一般保存在PS1环境变量中

在我的电脑上(Linux子系统在Windows电脑上),是这样的情况:

当我打开提示时,这是我看到的:

scampsd@DESKTOP-37TUCEQ:~$

当我请求 PS1 环境变量时,这是我看到的:

scampsd@DESKTOP-37TUCEQ:~$ echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[3[01;32m\]\u@\h\[3[00m\]:\[3[01;34m\]\w\[3[00m\]$

(注意最后的美元符号)

当我更改该变量时,会发生以下情况:

scampsd@DESKTOP-37TUCEQ:~$ export PS1=#
#

(不再有美元符号)

在Bash中,'$'符号表示登录系统的普通用户可以执行命令。如果您以 root 用户身份登录,提示符为“#”(井号或数字符号)。

要进一步了解提示的使用和历史,请查看 https://superuser.com/questions/57575/what-is-the-origin-of-the-unix-dollar-prompt