Skip to content

Instantly share code, notes, and snippets.

@zhum
zhum / bash-cheatsheet.sh
Last active June 6, 2025 23:27
Bash script sheatsheet
#!/usr/bin/env bash
# latest version is here: https://gist.github.com/zhum/b00b6c55e0559d0684796191eecf21d9
# shellcheck disable=all
#-------------- options --------------
set -e # stop on any command fail
set -E # generate ERR exception on aliases, functions, and commands in if/while/until conditions
set -u # stop on any unbound variable
set -o pipefail # stop on any fail with pipe
@zhum
zhum / bashscript-template.sh
Last active May 1, 2023 10:41
Bash script template with usefull things
#!/usr/bin/env bash
#
# YOUR DESCRIPTION HERE
#
#
# check it with https://www.shellcheck.net/
# set -e = FAIL if any command fails
# set -o pipefail = FAIL if any command in the pipe fails
# set -u = FAIL if any variable is used, but not initialized