{"id":22316668,"url":"https://github.com/developerstoolbox/bash-snippets","last_synced_at":"2025-08-10T22:07:53.250Z","repository":{"id":114323416,"uuid":"376242137","full_name":"DevelopersToolbox/bash-snippets","owner":"DevelopersToolbox","description":"A collection of bash snippets.","archived":false,"fork":false,"pushed_at":"2025-08-04T06:10:44.000Z","size":185,"stargazers_count":11,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-04T09:38:04.369Z","etag":null,"topics":["bash","bash-snippets","snippets","wolfsoftware"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevelopersToolbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["WolfSoftware","TGWolf"]}},"created_at":"2021-06-12T08:43:15.000Z","updated_at":"2025-08-04T06:09:07.000Z","dependencies_parsed_at":"2024-06-24T06:24:50.142Z","dependency_job_id":"d43d78a4-26ca-4906-b91d-a236c39d8578","html_url":"https://github.com/DevelopersToolbox/bash-snippets","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/DevelopersToolbox/bash-snippets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fbash-snippets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fbash-snippets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fbash-snippets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fbash-snippets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevelopersToolbox","download_url":"https://codeload.github.com/DevelopersToolbox/bash-snippets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevelopersToolbox%2Fbash-snippets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269794113,"owners_count":24476745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","bash-snippets","snippets","wolfsoftware"],"created_at":"2024-12-03T23:07:24.654Z","updated_at":"2025-08-10T22:07:53.227Z","avatar_url":"https://github.com/DevelopersToolbox.png","language":"Shell","readme":"\u003c!-- markdownlint-disable --\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/\"\u003e\n        \u003cimg src=\"https://cdn.wolfsoftware.com/assets/images/github/organisations/developerstoolbox/black-and-white-circle-256.png\" alt=\"DevelopersToolbox logo\" /\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets/actions/workflows/cicd.yml\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/DevelopersToolbox/bash-snippets/cicd.yml?branch=master\u0026label=build%20status\u0026style=for-the-badge\" alt=\"Github Build Status\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets/blob/master/LICENSE.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/DevelopersToolbox/bash-snippets?color=blue\u0026label=License\u0026style=for-the-badge\" alt=\"License\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/created-at/DevelopersToolbox/bash-snippets?color=blue\u0026label=Created\u0026style=for-the-badge\" alt=\"Created\"\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/v/release/DevelopersToolbox/bash-snippets?color=blue\u0026label=Latest%20Release\u0026style=for-the-badge\" alt=\"Release\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/release-date/DevelopersToolbox/bash-snippets?color=blue\u0026label=Released\u0026style=for-the-badge\" alt=\"Released\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets/releases/latest\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/commits-since/DevelopersToolbox/bash-snippets/latest.svg?color=blue\u0026style=for-the-badge\" alt=\"Commits since release\"\u003e\n    \u003c/a\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets/blob/master/.github/CODE_OF_CONDUCT.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Code%20of%20Conduct-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets/blob/master/.github/CONTRIBUTING.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contributing-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets/blob/master/.github/SECURITY.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Report%20Security%20Concern-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/DevelopersToolbox/bash-snippets/issues\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Get%20Support-blue?style=for-the-badge\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Overview\n\nThis is a collection of useful(ish) bash snippets. The snippets are all simple self-contained pieces of code (a class or subroutine), but non of them are large enough to require having a repository in their own right.\n\n## Bash Snippets\n\n| Name                                                                            | Description                                                                                                                                              |\n| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| [abs.sh](src/abs/abs.sh)                                                        | The Math. abs() function returns the absolute value of a number. That is, it returns x if x is positive or zero, and the negation of x if x is negative. |\n| [array-contains.sh](src/array-contains/array-contains.sh)                       | Check to see if an array contains a specific value.                                                                                                      |\n| [array-to-string.sh](src/array-to-string/array-to-string.sh)                    | Convert an array to a string with a custom separator and a final optional value.                                                                         | \n| [center-text.sh](src/center-text/center-text.sh)                                | Center any given text on the screen (optional define the screen width).                                                                                  |\n| [check-prerequisites.sh](src/check-prerequisites/check-prerequisites.sh)        | Check prerequisite commands are installed.                                                                                                               |\n| [compare-versions.sh](src/compare-versions/compare-versions.sh)                 | Compare two version strings with optional custom delimiter.                                                                                              |\n| [contains.sh](src/contains/contains.sh)                                         | Check to see if one string contains another.                                                                                                             |\n| [countdown.sh](src/countdown/countdown.sh)                                      | Display a simple countdown timer and message.                                                                                                            |\n| [error-messages.sh](src/error-messages/error-messages.sh)                       | Display error, warning and success messages.                                                                                                             |\n| [get-confirmation.sh](src/get-confirmation/get-confirmation.sh)                 | Get user confirmation for an action.                                                                                                                     |\n| [get-git-root.sh](src/get-git-root/get-git-root.sh)                             | Get the root directory of a given git repo (and handle correctly when it isn't a git repo).                                                              |\n| [get-script-info.sh](src/get-script-info/get-script-info.sh)                    | Get information about a script (full path and script name).                                                                                              |\n| [get-terraform-version.sh](src/get-terraform-version/get-terraform-version.sh)  | Get the current terraform version.                                                                                                                       |\n| [get-version-string.sh](src/get-version-string/get-version-string.sh)           | Extract a semver version from a string.                                                                                                                  |\n| [is-git-repo.sh](src/is-git-repo/is-git-repo.sh)                                | Check if a given directory contains a git repo.                                                                                                          |\n| [rollingback.sh](src/rollingback/rollingback.sh)                                | Using signals to create rollback functions for cleaner scripting.                                                                                        |\n| [stacktrace.sh](src/stacktrace/stacktrace.sh)                                   | Provide a stack trace for from main to the point of of calling the stacktrace.                                                                           |\n| [strict-mode.sh](src/strict-mode/strict-mode.sh)                                | An example of a 'strict' mode setup for bash scripts.                                                                                                    |\n| [sudo-librarian-puppet.sh](src/sudo-librarian-puppet/sudo-librarian-puppet.sh ) | Run librarian-puppet via sudo without changing default sudoers file (Debian 9 / Puppet 5).                                                               |\n| [terminal-or-not.sh](src/terminal-or-not/terminal-or-not.sh)                    | A script to allow to determine if your script is attached to a terminal, pipe or redirection.                                                            |\n| [untag.sh](src/untag/untag.sh)                                                  | A simple script to remove ALL tags from a git repo.                                                                                                      |\n| [using-colour.sh](src/using-colour/using-colour.sh)                             | An example of how to use colour (see [bash-colour-include](https://github.com/DevelopersToolbox/bash-colour-include) for a full working solution).       |\n| [using-set.sh](src/using-set/using-set.sh)                                      | Using 'set' for more robust shell scripting.                                                                                                             |\n| [variable-replace.sh](src/variable-replace/variable-replace.sh)                 | Replace template variables in a file with values from an associative array.                                                                              |\n| [verbose-mode.sh](src/verbose-mode/verbose-mode.sh)                             | Demonstration of script wide verbose/silent mode.                                                                                                        |\n\n\u003cbr /\u003e\n\u003cp align=\"right\"\u003e\u003ca href=\"https://wolfsoftware.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Created%20by%20Wolf%20on%20behalf%20of%20Wolf%20Software-blue?style=for-the-badge\" /\u003e\u003c/a\u003e\u003c/p\u003e\n","funding_links":["https://github.com/sponsors/WolfSoftware","https://github.com/sponsors/TGWolf"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperstoolbox%2Fbash-snippets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveloperstoolbox%2Fbash-snippets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperstoolbox%2Fbash-snippets/lists"}