SyntaxFix
Write A Post
Hire A Developer
Questions
If array elements don't contain spaces, another (perhaps more readable) solution would be:
if echo ${arr[@]} | grep -q -w "d"; then echo "is in array" else echo "is not in array" fi