文章目录
- 标准
- 简介
- 需要注意的一个问题
- shell的一大缺点
- set -x
- 各种括号的用法
- 参数相关
- 命令选项的空格可以省略
- bash a.sh
- exit
- not found 错误
- -
- --
- 怎么判断使用的是bash
- << !
- 时间相关的参数
- 遇到的错误
- 认识误区
- 使用
-
- type 关键字
- 变量
- 管道
- 后台运行
- ~
- ?*
- 星号与正则表达式的区别
- 重定向
- eval
- set 命令
- {!}
- {0##*/}
- %% 删除末尾匹配的字符串
- 获取硬盘分区的uuid
- 判断创建目录是否成功
- 切换用户组
- 反转字符串
- 字串判断
- 反转文件行
- chmod 777 -R *
- echo 不换行
- 获取目录
- 上次命令的执行结果;
- 读取文件
- date +"%y%m%d"
- to lower case
- read action < /dev/tty
- 判断是否为空, 前面加!,不为空
- 判断文件是否存在
- 执行命令后获取输出结果
- unzip 到特定文件到特定目录
- 分割字符取第二个
- 替换空格
- 文件中替换行
- 替换字符串
- 所有参数
- echo 输出解释转义字符
- 时间
- 字符串组装
- 数值计算
- 数组操作
- while 循环
- for 循环
- 比较 字符串
- case 或表达式
- 另一种if
- if && ||
- 读取参数
- 定义结构
- 下载文件
- 移动参数
- 参数个数
- 写log 到syslog
- 循环字符串中的单词/数组
- 算式
- tr
- xargs -n1
- 获取 pid
- 设置进程与cpu亲密度
- 获取主机名字
- 通过runcon运行命令
- 当前进程id
- 环境变量
- trap
- 错误
- 实例
- bash vs ksh
标准
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02
https://www.gnu.org/software/bash/
https://wiki.gentoo.org/wiki/Mksh
简介
就是Linux系统的一个外部接口,外壳。
Bash is the GNU Project’s shell—the Bourne Again SHell. This is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and the C shell (csh). It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification.
https://bugzilla.kernel.org/show_bug.cgi?id=217459