The snippet library.
Small, practical examples. Search by task or narrow things down below.
Read part of a shell string
Bash Scripts: Read part of a shell string with a small standalone Bash program.
Bash Scripts✓ Tested
Read positional parameters in a function
Bash Scripts: Read positional parameters in a function with a small standalone Bash program.
Bash Scripts✓ Tested
Read the first array element
Bash Scripts: Read the first array element with a small standalone Bash program.
Bash Scripts✓ Tested
Read the length of an ASCII string
Bash Scripts: Read the length of an ASCII string with a small standalone Bash program.
Bash Scripts✓ Tested
Repeat a command for several words
Bash Scripts: Repeat a command for several words with a small standalone Bash program.
Bash Scripts✓ Tested
Replace text with parameter expansion
Bash Scripts: Replace text with parameter expansion with a small standalone Bash program.
Bash Scripts✓ Tested
Store and iterate over an array
Bash Scripts: Store and iterate over an array with a small standalone Bash program.
Bash Scripts✓ Tested
Store text in a variable
Bash Scripts: Store text in a variable with a small standalone Bash program.
Bash Scripts✓ Tested
Test a function’s success status
Bash Scripts: Test a function’s success status with a small standalone Bash program.
Bash Scripts✓ Tested
Use a counted Bash loop
Bash Scripts: Use a counted Bash loop with a small standalone Bash program.
Bash Scripts✓ Tested
Use a fallback for an unset variable
Bash Scripts: Use a fallback for an unset variable with a small standalone Bash program.
Bash Scripts✓ Tested
Write and run a first Bash script
Bash Scripts: Write and run a first Bash script with a small standalone Bash program.
Bash Scripts✓ Tested