Bash
学习 Bash 脚本编程,从变量到健壮的生产级脚本。涵盖循环、数组、信号捕获、set -euo pipefail 以及服务器引导启动实战项目。
共 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 分钟
错误处理与 trap
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 导师会用你提问的语言来回答。
Roles that use Bash
See how hiring teams interview engineers on Bash, in production-like environments.
DevOps Engineer
Hire DevOps engineers who actually ship. Run live or take-home interviews in production-like Linux environments with Docker, Kubernetes, Terraform and CI/CD. See how they debug, automate, and work alongside AI.
See the interviewSite Reliability Engineer (SRE)
Hire SREs who actually run production. Live workspaces with metrics, logs, traces and a service that is starting to misbehave. We record every keystroke.
See the interviewInfrastructure Engineer
Hire infrastructure engineers who design systems your team can rely on. Interview them in real workspaces with Terraform, Ansible, cloud APIs and live failure scenarios.
See the interview