A comprehensive understanding of the powerful Shell, Bash special variables, the essence of advanced usage, and mastering script commands will help you become more efficient and effective in Linux work

A comprehensive understanding of the powerful Shell, Bash special variables, the essence of advanced usage, and mastering script commands will help you become more efficient and effective in Linux work.

Bash is a powerful shell that provides various special variables that can be used to manipulate and control the behavior of scripts. These variables provide basic information about the environment in which the script is running, including command-line arguments, the current process ID, and the status of the last command executed.

In this article, I'll provide an in-depth guide to all Bash's special variables, including examples of their use and common problems to avoid.

"$0"-  正在执行的脚本的名称。
"$1-$9" - 前九个命令行参数。
"$#"- 命令行参数的数量。
"$*"- 所有命令行参数作为单个字符串。
"$@"- 所有命令行参数作为一个数组。
"$?" - 上次执行的命令的退出状态。
"$$"  -<

Guess you like

Origin blog.csdn.net/u014374009/article/details/132383247