Testing of special symbols in shell scripts

#!/bin/bash  

VAR="hello world"

echo $VAR

# $0:	类似于C中的argv[0] ---- 描述可执行程序名
echo -n "elf file name: "
echo $0

# $1-$N:  类似于C中的argv[1]--argv[N] 命令行参数
echo -n "parameter: "
echo $1

# $#:	计算命令行参数的个数(不包含 argv[0])
echo -n "argc num: "
echo $#

# $*/$@:  表示所有的 argv 命令行参数(不包含 argv[0])
echo "all parameters: "
echo $*
echo "all parameters: "
echo $@

# $$: 	取出本进程的进程号 
echo -n "pid: "
echo $$


Test Results

Insert picture description here

#!/bin/bash 

echo $0
echo $1 
echo $2
echo $9
echo ${10}

echo $*
echo $@

echo $#



Test Results

Insert picture description here

Guess you like

Origin blog.csdn.net/zxy131072/article/details/108519516