Created
March 19, 2019 10:18
-
-
Save imvaskii/b3adb93e2f5f81693375a6c9ba4adab3 to your computer and use it in GitHub Desktop.
Bash in_array function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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