关于linux shell脚本开头的#!/bin/sh

打开终端,进入/bin/
ls 一下
会见到 bash  sh 呢两个文件。

其实距地系两个唔同既shell 解析器。

如果在脚本a.sh   开头写入
#!/bin/sh

那么执行./a.sh 时候  就相当于 sh a.sh
同理 开头写入
#!/bin/bash
执行./a.sh 时候  就相当于 bash  a.sh

如果写入
#!/bin/sh
而执行时 用 bash a.sh 的话, 会强制用bash 来执行

距地两个有区别吗?
有,
如果有一条语句  
echo ${PATH:0:1}

用bash执行会返回 $PATH变量的第1个字符

而用sh执行系回报错咖!

相关文章

系ubuntu 下面打开终端输入:sudo apt-get install sendmail...
依家我有1个软件goagent目录(大家懂得) 放在/home/gateman/...
其实我想讲的是 cp -L关于-L参数的解释:-L, --dereferenc...
原地址:http://www.rjgc.net/control/content/content.php?...
chroot,即 change root directory (更改 root 目录)。在 li...
简单解析下, stdin就是标准输入, stdout就是标准。举个例子...