Linux shell 脚本中, $@ 和$# 分别是什么意思?

转自:https://zhidao.baidu.com/question/412833470.html

$@:表示所有脚本参数的内容

$#:表示返回所有脚本参数的个数。

示例:编写如下shell脚本,保存为test.sh

#!/bin/sh

echo "number:$#"

echo "argume:$@"

执行脚本:

./test.sh first_arg second_arg

说明:给脚本提供了两个参数,所以$#输出的结果是2,$@代表了参数的内容!

原文地址:https://www.cnblogs.com/YuyuanNo1/p/8459371.html