本文共 444 字,大约阅读时间需要 1 分钟。
告知shell读取一连串的参数,然后再依照参数本身的特性来执行。
tom@tom-linuxer:~$ cat file1.sh#!/bin/bashecho "This is a file1"tom@tom-linuxer:~$ myfile="cat file1.sh"tom@tom-linuxer:~$ eval $myfile#!/bin/bashecho "This is a file1"
tom@tom-linuxer:~$ cat test.sh #!/bin/bashecho $*echo $@echo $#echo $2eval echo \$$#tom@tom-linuxer:~$ ./test.sh 3 5 6 273 5 6 273 5 6 274527
说明:
$#: 是参数个数 $N: 输入第N个参数第一扫描,则转换$#为4,然后在打印$4,第二次扫描结果是27。
转译$确保,第一个$不会被其他组合。转载地址:http://gxfab.baihongyu.com/