1.$0-$9及$# $@的使用
demo_arg 内容
#!/bin/bash
echo "程序名:$0"
echo "命令传递参数个数:$#"
echo "参数值分别是:$1 $2 $3 $4 $5 $6 $7 $8 $9"
echo "所有参数:$@"
exit 0
终端命令:
$chmod u+x demo_arg
$./demo_arg a b c d e f g h i
2.set用法
demo_set内容
#!/bin/bash
filename="$1"
set $ (ls -il $filename)
inode="$1"
size="$6"
echo "Name Inode Size"
echo "$filename $inode $size"
exit 0
终端命令:
$chmod u+x demo_set
$./demo_set demo_set