Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁。Shell 既是一种命令语言,又是一种程序设计语言。
Shell 是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核的服务。
Ken Thompson 的 sh 是第一种 Unix Shell,Windows Explorer 是一个典型的图形界面 Shell。
- shell脚本编程学习笔记
Something I hope you know before go into the coding~
First, please watch or star this repo, I'll be more happy if you follow me.
Bug report, questions and discussion are welcome, you can post an issue or pull a request.
- GitBook:https://yifengyou.gitbooks.io/learn-shell/content/
- GitHub:https://github.com/yifengyou/learn-shell/
- GitPage:https://yifengyou.github.io/learn-shell/
- 《Linux命令行与Shell脚本编程大全》
- 《精通UNIX.shell脚本编程》
- 《实战LINUX_SHELL编程与服务器管理》
- 《Shell脚本编程诀窍——适用于Linux、Bash等》
- 基础永远值得花费90%的精力去学习加强。厚积而薄发~
- 实践的重要性
- [[ ... && ... && ... ]] 和 [ ... -a ... -a ...] 不一样,[[ ]] 是逻辑短路操作,而 [ ] 不会进行逻辑短路
- [[ ... ]]进行算术扩展,而[ ... ]不做
if [ X"${var}" != "X1" ];then
...
fi
&& and 判断
if [ X"${var}" != "X1" -a X"${var2}" != "X2" ];then
...
fi
if [[ X"${var}" != "X1" and X"${var2}" != "X2" ]];then
...
fi
if [[ X"${var}" != "X1" ]] and [[ X"${var2}" != "X2" ]];then
...
fi
|| or 判断
if [ X"${var}" != "X1" -o X"${var2}" != "X2" ];then
...
fi
if [[ X"${var}" != "X1" || X"${var2}" != "X2" ]];then
...
fi
if [[ X"${var}" != "X1" ]] or [[ X"${var2}" != "X2" ]];then
...
fi
死循环写法
while [ 1 ];do
...
done