Shell 文件包含
1 li@ubuntu:~/test$ cat b.sh 2 #!/bin/bash 3 4 myName="Nicholas" 5 6 li@ubuntu:~/test$ cat a.sh 7 #!/bin/bash 8 9 . ./b.sh 10 #source ./b.sh 11 12 echo "My name is $myName ..." 13 li@ubuntu:~/test$ chmod +x a.sh 14 li@ubuntu:~/test$ ./a.sh 15 My name is Nicholas ... 16 li@ubuntu:~/test$
被包含的脚本不需要有执行权限

浙公网安备 33010602011771号