tldr/pages.zh/common/bash.md

38 lines
725 B
Markdown
Raw Normal View History

2019-08-14 14:41:34 +01:00
# bash
> Bourne-Again SHell.
2019-10-18 04:30:29 +01:00
> 兼容`sh`的命令行解释器.
> 更多信息: <https://gnu.org/software/bash>.
2019-08-14 14:41:34 +01:00
2019-10-18 03:33:27 +01:00
- 启动交互式 shell:
2019-08-14 14:41:34 +01:00
`bash`
2019-10-19 07:12:27 +01:00
- 执行命令:
2019-08-14 14:41:34 +01:00
`bash -c "{{command}}"`
2019-10-19 07:12:27 +01:00
- 执行脚本文件:
2019-08-14 14:41:34 +01:00
`bash {{file.sh}}`
2019-10-19 07:12:27 +01:00
- 执行脚本文件,并将所有执行过的命令输出到终端:
2019-08-14 14:41:34 +01:00
`bash -x {{file.sh}}`
2019-10-19 07:12:27 +01:00
- 执行脚本文件,并在第一个错误处终止:
2019-08-14 14:41:34 +01:00
`bash -e {{file.sh}}`
- 从输入 (stdin) 读取命令:
2019-08-14 14:41:34 +01:00
`bash -s`
2019-10-18 03:33:27 +01:00
- 将跟随的所有选项原样传递到要执行的脚本文件(可与`-s`选项共用来将选项传递到来自输入的命令 / 脚本)
2019-08-14 14:41:34 +01:00
`bash --`
2019-10-18 03:33:27 +01:00
- 打印 bash 的版本信息 (使用`echo $BASH_VERSION`来获得纯粹的版本字符串):
2019-08-14 14:41:34 +01:00
`bash --version`