入门
Bash
学习 Bash 脚本编程,从变量到健壮的生产级脚本。涵盖循环、数组、信号捕获、set -euo pipefail 以及服务器引导启动实战项目。
12 节5.7h 实操11 种语言
免费开始学习Bash 课程共 12 节,按顺序
- 120 分钟
什么是 Bash
Shell vs terminalBash vs sh vs zshInteractive shell vs scriptWhere Bash fits in DevOps - 225 分钟
Shebang 与你的第一个脚本
Shebang#!/usr/bin/env bashChmod +x./script.sh vs bash script.shExit codes - 325 分钟
变量与引号
Variable assignmentDouble quotes vs single quotes${var} bracesCommand substitution $(...) - 430 分钟
条件语句与测试
If statement[[ ]] testsString testsFile tests -f -d -e&& and ||Case statement - 525 分钟
循环
For loopWhile loopUntil loopFor f in *.txt globbingC-style for loopBreak and continue - 625 分钟
函数
Function definitionPositional args $1 $@ $#Return for exit codesEcho for outputLocal variables - 725 分钟
数组
Indexed arrays${arr[@]}${#arr[@]} lengthAssociative arrays declare -AIterating arrays - 825 分钟
字符串与算术展开
${var#prefix}${var%suffix}${var//old/new}$(( arith ))Printf formatting - 925 分钟
IO 重定向与管道
>>><2>2>&1&>+3 - 1030 分钟
错误处理与陷阱
Set -eSet -uSet -o pipefailTrap on EXITTrap on ERRCleanup functions - 1125 分钟
调试与最佳实践
Bash -xSet -xShellcheckSafe quotingNever parse ls[[ vs [+1 - 1260 分钟
综合实战:服务器引导脚本
Idempotent provisioningInstalling packagesCreating usersSSH key setupSystemd timersLogging+2
用你的语言学习 Bash
每一节课、测验和导师回复都以你的语言显示。AI 导师会用你提问的语言来回答。
