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,$@代表了参数的内容!

posted on 2018-02-22 16:39  小甜瓜安东泥  阅读(4533)  评论(0编辑  收藏  举报