Retry a shell command with backoff
Re-run a flaky command a few times with increasing delays and a clear failure exit code.
Shell scripts and tooling for repetitive tasks.
Loading snippets…
11 snippets
Re-run a flaky command a few times with increasing delays and a clear failure exit code.
Handle -v, -o FILE and -h in a bash script with getopts and a usage message.
Process many files concurrently with xargs -P, safely handling spaces and newlines in names.
Small log, warn and die helpers that write ISO timestamps to stderr and keep stdout clean for data.
Get the files added, copied, modified or renamed on your branch, useful for linting or testing only what changed.
Safely remove old log or temp files with find, previewing first and handling unusual filenames.
Create a temp directory and guarantee it is removed when the script exits, fails or is interrupted.
Fail early with a helpful message when a script depends on tools that are missing.
Archive a directory with a sortable timestamp and delete older backups beyond a retention count.
Clean up merged local branches safely, excluding main, master, develop and the current branch.
Fail fast on errors, unset variables and broken pipes, and clean up temp files with a trap.