Libraries#
Bash has no package manager of its own. Re-use is achieved by sourcing other shell files, calling external programs, or distributing helper functions in shared directories.
Built-in Helpers#
Common builtins worth knowing:
printf, format and printread, read a line from a streammapfile/readarray, read lines into an arraytrap, run a handler on signals orEXITgetopts, parse short flags
External Tools#
Most “library” functionality comes from coreutils and friends:
Text:
grep,sed,awk,cut,tr,sort,uniqFiles:
find,xargs,stat,rsyncHTTP:
curl,wgetJSON:
jqProcess:
ps,pgrep,kill,timeout
Sourcing a Module#
$ log::info() { printf '[INFO] %s\n' "$*"; }
$ log::warn() { printf '[WARN] %s\n' "$*" >&2; }
$ source "$(dirname "$0")/lib/log.sh"
$ log::info "starting"