1. shell 脚本里的: $0、$1、$2、$@、$*、$#、$? 这七个葫芦娃兄弟分别代表啥呢?
2. 一图胜千言
测试程序:
#!/bin/bash
echo "shell file iteslt name :$0"
echo "the first argument :$1"
echo "the second argument:$2"
echo "all the argruments:$@"
echo "all the argruments:$*"
echo "the total count of argrumnets:$#"
echo "the return value of last command:$?"
测试结果:
book@book-virtual-machine:/work/mytmp$
book@book-virtual-machine:/work/mytmp$ ./test.sh arg1 arg2
shell file iteslt name :./test.sh
the first argument :arg1
the second argument:arg2
all the argruments:arg1 arg2
all the argruments:arg1 arg2
the total count of argrumnets:2
the return value of last command:0
book@book-virtual-machine:/work/mytmp$
book@book-virtual-machine:/work/mytmp$