Shell Scripting MIT
FreeAutomate command-line tasks with MIT's Missing Semester shell scripting lecture
FreeFree tier
About Shell Scripting MIT
A lecture from MIT's Missing Semester course covering shell scripting and shell tools, designed to fill critical gaps in computing ecosystem literacy. The material focuses on bash scripting, including variables, control flow, functions, special variables, return codes, and command substitution, as well as practical tools for automating repetitive tasks, using version control, editing text efficiently, and working with remote machines. The course is pragmatic and hands-on, providing knowledge that can be immediately applied to improve command-line productivity.
Key Features
Bash scripting with variables, control flow, and functions
String handling with single and double quotes
Special variables ($0, $1, $@, $#, $?, $$, !!, $_)
Return codes and short-circuit operators (&&, ||)
Command substitution for capturing output
Practical shell tools and history navigation tricks
Version control basics (git bisect, revert)
Text editing with Vim macros
Remote machine management with SSH and tmux
Pros & Cons
Pros
- Teaches practical, immediately applicable shell skills
- Covers often overlooked but essential topics for developers
- Hands-on examples with real-world relevance
- Free and open-source educational material from MIT
- Part of a well-regarded course series (Missing Semester)
Cons
- Material is limited to a single lecture; advanced scripting topics not covered in depth
- Assumes basic familiarity with the command line
- Live lectures are only available to MIT community; public materials are static
Best For
Automating repetitive command-line tasks with scriptsCreating custom command-line utilities for daily workflowsImproving efficiency in shell usage and reducing manual errorsLearning foundational computing ecosystem topics often missing from CS curriculaPreparing for system administration and developer tool proficiency
FAQ
What is shell scripting?
Shell scripting is writing a series of commands in a shell language like bash, with variables, control flow, and functions, optimized for shell-related tasks such as command pipelines and file I/O.
How do I assign a variable in bash?
Use the syntax foo=bar without spaces. For example, foo=bar assigns the value bar to the variable foo.
What is the difference between single and double quotes in bash?
Double quotes allow variable substitution (e.g., echo "$foo" prints the value of foo), while single quotes treat the string literally (e.g., echo '$foo' prints $foo).
What are special variables like $0, $1, $@ in bash?
$0 is the script name, $1 to $9 are positional arguments, $@ is all arguments, $# is the number of arguments, $? is the return code of the previous command, $$ is the PID, !! is the entire last command, and $_ is the last argument of the previous command.
How can I use return codes to conditionally execute commands?
Use && (and) to run a command only if the previous succeeded, and || (or) to run a command only if the previous failed. For example, false || echo 'Oops, fail' prints the message.