Bash mktemp: Create Temporary Files and Directories Safely
Learn how Bash mktemp creates temporary files and directories safely, use templates and TMPDIR, register trap EXIT cleanup, avoid unsafe mktemp -u, and atomically replace files on the same filesystem.
Logging in Bash Scripts
Learn Bash script logging: stdout vs stderr, a minimal log function with levels and timestamps, tee, exec redirects, logger for syslog/journald, systemd capture, rotation, and keeping secrets out of logs.
Bash set vs shopt: How Shell Options Work
Learn why Bash has both set and shopt, how to enable and check shell options, and when to use nullglob, failglob, lastpipe, and inherit_errexit in scripts.
Bash Error Handling: Practical Patterns for Reliable Scripts
Learn Bash error handling with exit codes, set -e exceptions, trap ERR, expected grep and diff statuses, bounded retries with backoff, batch partial failure, stderr diagnostics, and trap EXIT cleanup.
Bash Strict Mode: `set -euo pipefail` Explained
Learn what set -euo pipefail does in Bash, when set -e does not exit, how nounset and pipefail behave, and the common strict-mode pitfalls in functions, pipelines, and command substitution.
How to Read a File Line by Line in Python
Learn how to read a text file line by line in Python using file iteration and readline(), handle newlines and encodings, add line numbers, and process large files without loading the entire file into memory.
Bash Subshells: () vs {}, Variable Scope and Examples
Learn how Bash subshells work, when ( ) isolates variables and cd, how { } differs, and why pipelines and command substitution can lose shell state.
Bash Process Substitution: <() and >()
Bash process substitution with <() and >(): expose command output as a file path, compare pipes and $(), keep while read in the current shell, and handle async exit status.
Bash File Descriptors and exec
Open Bash file descriptors beyond 0/1/2 with exec, write with >&3, read with read -u, save and restore stdout, use dynamic {fd} allocation, and close FDs to avoid leaks.
Bash Heredoc: <<EOF, Variables, Indentation and Here Strings
Learn Bash heredoc and here-string syntax: quoted delimiters, <<- tab stripping, variable assignment, sudo tee, SSH expansion, and tested <
Bash Redirection: stdin, stdout and stderr
Bash redirection explained with file descriptors 0, 1, and 2, left-to-right 2>&1 semantics, split logs, append, exec, and why sudo does not fix a failed shell redirect.
Bash Pipes: pipefail, PIPESTATUS and Exit Codes
Learn Bash pipes: connect stdout between commands, use pipefail and PIPESTATUS for pipeline exit codes, pipe stderr with |&, and avoid subshell and SIGPIPE surprises.
Bash Parameter Expansion: ${var:-}, Substrings, Trim & Replace
Bash parameter expansion explained with ${var:-default}, substring slicing, trim, replace, and a truth table for default, assignment, alternate, and error operators covering unset vs empty variables.
Bash Expansion Order: How Shell Expansion Works
Learn Bash expansion order from brace and variable expansion to word splitting, globbing, and quote removal, with tested examples.
Bash Command Substitution: Syntax, Examples and $() vs Backticks
Learn Bash command substitution with $(): capture command output in variables, compare backticks, handle quoting and newlines, and understand subshell behavior.
Split a String into an Array in Bash
Split one Bash string into array elements with IFS and read -ra, handle comma colon and pipe delimiters, preserve spaces, avoid unsafe arr=($string) globbing, and know when IFS is not a CSV parser.
Bash IFS and Word Splitting Explained
Learn how Bash IFS controls word splitting on unquoted expansions, how whitespace delimiters differ from commas and colons, and safe patterns with read, local IFS, and "$@".
Bash mapfile / readarray: Read Lines into an Array
Load files and command output into Bash indexed arrays with mapfile and readarray: -t for clean lines, -n and -s for limits, -O for a starting index, -d for custom delimiters, and NUL-safe find -print0 paths.
Bash Associative Arrays: Key-Value Maps
Create Bash associative arrays with declare -A, store string keys and values, loop keys safely, count occurrences, use maps as sets, and avoid common quoting and ordering mistakes.
Bash Arrays: Create, Append, Loop, Slice and Delete
Learn Bash indexed arrays: create, access, append, loop, slice, and delete elements safely with "${array[@]}", sparse indices, negative indexes, and command argument arrays.
Bash getopts: Parse Short Options and Handle Long Options
Learn Bash getopts for short flags, OPTARG and OPTIND, silent error mode, shift after parsing, reusable functions, manual long options, and when to use GNU getopt instead.
Bash source Command: Source vs Execute a Script
Learn when to use Bash source or dot versus bash file or ./file, what changes persist in the current shell, how sourced arguments and return status work, PATH lookup with sourcepath, and Bash 5.3 source -p path.
Bash Functions: Arguments, Variables and Return Values
Define Bash functions with arguments, local variables, return status, stdout capture, and nameref output parameters, including dynamic scope and subshell behavior.
Create Interactive Menus with Bash select
Build numbered terminal menus in Bash with select, customize the PS3 prompt, read choices from REPLY, validate invalid input, use arrays and function arguments, and add a quit option with break.
Bash break and continue
Use Bash break and continue to exit loops early or skip an iteration, including nested levels, while read parsing, and select menus.
Read a File Line by Line in Bash
Read a text file line by line in Bash with while IFS= read -r, preserve whitespace and backslashes, handle files without a final newline, and avoid pipeline subshell traps.
Bash while Loop
Use Bash while loops with command exit status, arithmetic counters, infinite loops, retries, brief read loops, the pipeline subshell trap, until, and do-while emulation.
Bash Wildcards and Globbing
Learn Bash globbing and wildcards with tested examples for *, ?, bracket patterns, nullglob, dotglob, nocaseglob, globstar, extglob, quoting, arrays, and safe loops over matched files.
Bash for Loop: Syntax and Examples
Learn Bash for loop syntax with practical examples for lists, arrays, files, script arguments, numeric ranges, and C-style counters.
Bash Regex: =~ and BASH_REMATCH
Match text in Bash with [[ =~ ]], capture groups in BASH_REMATCH, store regex in variables, avoid RHS quoting traps, and understand POSIX ERE limits versus PCRE.






