Master Bash Scripting For Automation with 120 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.
Sample card
What is Bash?
Bash (Bourne Again SHell) is a Unix shell and command language written as a free software replacement for the Bourne shell (sh). It is the default login shell on most Linux distributions and macOS (until Catalina).
Q · 1 of 120
What is Bash?
Q · 2 of 120
What file extension is conventionally used for Bash scripts?
Q · 3 of 120
What must the first line of an executable Bash script be?
Bash (Bourne Again SHell) is a Unix shell and command language written as a free software replacement for the Bourne shell (sh). It is the default login shell on most Linux distributions and macOS (until Catalina).
.sh. While not strictly required for execution, .sh signals intent and lets tooling treat the file as a shell script.
A shebang line, e.g. #!/usr/bin/env bash or #!/bin/bash, which tells the kernel which interpreter to invoke.
chmod +x script.sh (or chmod 755 script.sh).
./script.sh. The dot-slash is required because the current directory is not normally in $PATH.
sh script.sh and ./script.sh?sh explicitly invokes the sh interpreter and ignores the shebang, so Bash-specific features may break. ./script.sh honors the shebang and uses the listed interpreter.
A named storage location for a value, assigned with NAME=value (no spaces around =) and referenced as $NAME or ${NAME}.
Export it: export VAR=value or VAR=value; export VAR. Without export, the variable is local to the current shell.
$VAR and ${VAR}?Both expand the value, but ${VAR} disambiguates boundaries, e.g. ${VAR}suffix vs the ambiguous $VARsuffix. It also enables parameter expansion features like default values and substring operations.
${VAR:-default} substitutes default if VAR is unset or empty. ${VAR:=default} also assigns the default back to VAR.
${VAR:?message} do?Prints message to stderr and exits the script with status 1 if VAR is unset or empty. Useful for required-input guards.
The arguments passed to a script or function, accessed as $1, $2, ..., with $0 being the script name and $# the count of arguments.
Flashcards
Flip to reveal
Focus Mode
Spaced repetition
Multiple Choice
Test your knowledge
Type Answer
Active recall
Learn Mode
Multi-round mastery
Match Game
Memory challenge