Skip to content

Instantly share code, notes, and snippets.

@imvaskii
Created March 19, 2019 10:18
Show Gist options
  • Save imvaskii/b3adb93e2f5f81693375a6c9ba4adab3 to your computer and use it in GitHub Desktop.
Save imvaskii/b3adb93e2f5f81693375a6c9ba4adab3 to your computer and use it in GitHub Desktop.
Bash in_array function.
# Check item in an array
#
# @arg1 needle
# @arg2 array
#
# return boolean
inarray() {
for item in "${@:2}"; do [[ "$item" == "$1" ]] && return 0; done
return 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment