#!/bin/bash
来源:互联网 发布:apple好玩的软件 编辑:程序博客网 时间:2024/05/21 21:03
#!/bin/bash是指此脚本使用/bin/bash来解释执行。
其中,#!是一个特殊的表示符,其后,跟着解释此脚本的shell路径。
bash只是shell的一种,还有很多其它shell,如:sh,csh,ksh,tcsh,...
我们可以通过以下一个示例来进行实验,了解#!/bin/bash的使用。
1)#!/bin/bash只能放在第一行,如果后面还有#!,那么只能看成是注释。
这里有三个脚本(脚本都要使用”chmod +x scriptname“命令来获得可执行权限):
tbash1.sh:
#!/bin/sh
source abc
echo "hello abc"
tbash2.sh:
#!/bin/bash
source abc
echo "hello abc"
tbash3.sh:
source abc
echo "hello abc"
三个脚本执行的结果:
[nsvc@localhost other]$ ./tbash1.sh
./tbash1.sh: line 2: abc: No such file or directory
注:当source命令执行有问题时,sh不再往下面执行。
[nsvc@localhost other]$ ./tbash2.sh
./tbash2.sh: line 2: abc: No such file or directory
hello abc
注:当source命令执行有问题时,bash继续执行下面命令。
[nsvc@localhost other]$ ./tbash3.sh
./tbash3.sh: line 1: abc: No such file or directory
hello abc
注:自身登录系统所在的shell是bash。所以,当source命令执行有问题时,bash继续执行下面命令。
0 0
- #!/bin/bash
- #!/bin/bash
- #!/bin/bash
- #!/bin/bash
- #!/bin/bash
- #!/bin/bash
- #!/bin/bash
- #!/bin/bash
- #!/bin/bash
- #!bin/bash
- #!/bin/bash
- /bin/bash
- #!/bin/bash
- #!/bin/bash
- #!/bin/sh & #!/bin/bash
- #!/bin/bash #!/bin/sh
- #!/bin/bash 与#!/bin/sh
- #!/bin/bash 与#!/bin/sh
- cloudera安装报错 socket.gaierror: [Errno -2] Name or service not known
- 从源码分析 Android dexClassLoader 加载机制原理
- Android:开发规范
- 209,自定义代理例子与数据加载结合
- #ifdef __cplusplus extern "C" { #endif 的解释
- #!/bin/bash
- C# string字符串转换为字节数组和转换为16进制的字符串形式
- Android 代码动态加载布局
- #define中的#,\,##,#@符号,以及#define的基本应用
- 档案重要吗有什么作用(转载记录避免以后麻烦)
- A Tale of Twenty-Two Million Citi Bikes: Analyzing the NYC Bike Share System
- 摄像头采集,264编码,live555直播(2)
- Eclipse 使用 Link 方式进行插件的安装
- 给定点的json文件,绘制路径