Results for “Bash Scripts”
Small, practical examples. Search by task or narrow things down below.
Replace every occurrence in a string
Substitute text directly with Bash parameter expansion.
replace✓ Tested
Return text from a shell function
Capture a function’s output with command substitution.
function✓ Tested
Split a line into named fields
Read a simple delimiter-separated line into variables.
read✓ Tested
Sum a range of integers
Use an arithmetic loop without launching external processes.
arithmetic✓ Tested
Use a default value for an unset variable
Supply a fallback without changing the original variable.
parameter expansion✓ Tested
Allow embedded scripts without granting same-origin access
HTML: Grant only allow-scripts so the sandboxed document retains an opaque origin.
HTML✓ Tested
Block scripts in an embedded document
HTML: An empty sandbox attribute applies the default set of restrictions, including blocking script execution.
HTML✓ Tested
Choose Bash with pipefail for build commands
Docker / Compose: SHELL changes the interpreter for subsequent shell-form instructions.
Docker / Compose✓ Tested
Write subscripts and superscripts in ordinary text
HTML: Sub and sup position short annotations such as formula indices and exponents.
HTML✓ Tested
Abort a conflicting cherry-pick
Git: Abort removes the incomplete replay and returns to the previous branch state.
Git✓ Tested
Abort a conflicting rebase
Git: Abort returns the branch to its state before the rebase attempt.
Git✓ Tested
Abort a merge with unresolved conflicts
Git: Abort restores the pre-merge state in this clean practice repository.
Git✓ Tested