/bin/sh 与 /bin/bash 的区别
/bin/sh 与 /bin/bash 的区别,用 : 截取字符串不是POSIX 标准的。
区别
sh一般设成bash的软链 (symlink)
- ls -l /bin/sh
- lrwxrwxrwx 1 root root 4 Sep 14 04:45 /bin/sh -> dash
- 在一般的 linux 系统当中(例外如
FreeBSD,OpenBSD等),使用sh调用执行脚本相当于打开了bash的POSIX标准模式 - 也就是说
/bin/sh相当于/bin/bash --posix
所以,它们之间的各种差异都是来自 POSIX 标准模式 和 bash 的差异,比如 用 : 截取字符串,不能用 let , 遇错中断 等等,在使用时需要注意。
参考
- [Difference between sh and bash] http://stackoverflow.com/questions/5725296/difference-between-sh-and-bash
- [/bin/bash和/bin/sh的区别] http://www.cppblog.com/erran/archive/2012/05/24/176038.aspx
- [#!/bin/sh與#!/bin/bash的區別] http://fanli7.net/a/bianchengyuyan/_NET/20130916/424894.html
#----------All efforts I have paid today...
浙公网安备 33010602011771号