View on GitHub

🧰 Utilities.sh

for a Better BASH experience!

download .ZIPdownload .TGZ

Utilities for a better BASH experience - inspired by Underscore.js

Download the latest version by clicking one of the download links above or:

curl -o- https://utilities.sh/installer.sh | bash

Array Utilities


Array Utilities

any

Assert provided items contain item matching given conditional expression.

if _ any =~ ^-- "$@"
then
  echo "At least one argument is a --flag"
fi

includes

Assert provided items contain given item.

if _ includes "item" "$@"
then
  echo "The arguments include 'item'"
fi

map

Map provided items to given expression.

ls
# => hello.sh world.sh

ls | _ map '${_%.sh}'
# => hello world

Store Results

source $(_ _)

# Save results in an array
_ map results = _:0:1 "Hello" "World"

echo "${#results[@]} results: ${results[*]}"
# => "2 results: H W"