The snippet library.
Small, practical examples. Search by task or narrow things down below.
Calculate with integer arithmetic
Bash Scripts: Calculate with integer arithmetic with a small standalone Bash program.
Bash Scripts✓ Tested
Capture a command’s output
Bash Scripts: Capture a command’s output with a small standalone Bash program.
Bash Scripts✓ Tested
Choose an action with case
Bash Scripts: Choose an action with case with a small standalone Bash program.
Bash Scripts✓ Tested
Choose between two script branches
Bash Scripts: Choose between two script branches with a small standalone Bash program.
Bash Scripts✓ Tested
Compare two text values
Bash Scripts: Compare two text values with a small standalone Bash program.
Bash Scripts✓ Tested
Count array elements
Bash Scripts: Count array elements with a small standalone Bash program.
Bash Scripts✓ Tested
Count down with a while loop
Bash Scripts: Count down with a while loop with a small standalone Bash program.
Bash Scripts✓ Tested
Declare a fixed configuration value
Bash Scripts: Declare a fixed configuration value with a small standalone Bash program.
Bash Scripts✓ Tested
Define and call a shell function
Bash Scripts: Define and call a shell function with a small standalone Bash program.
Bash Scripts✓ Tested
Increase an integer variable
Bash Scripts: Increase an integer variable with a small standalone Bash program.
Bash Scripts✓ Tested
Limit a beginner function variable to local scope
Bash Scripts: Limit a beginner function variable to local scope with a small standalone Bash program.
Bash Scripts✓ Tested
Read a line without losing backslashes
Bash Scripts: Read a line without losing backslashes with a small standalone Bash program.
Bash Scripts✓ Tested