Search Element In An Array in Linux

In this blog, Sharing the code to Search an Element in an Array using Shell scripting. a =(1 2 3 4) ## Array of 4 Elementsi=0x=2 ##x is the element which need to be searched in an Arraylen=${#a[@]} ## It gives the length of an Arraylen1=$(( $len – 1 )) ##len1 is used to display if element is not present in an array.while [ $i -lt $len ]doif [[ ${a[i]} -eq $x ]]thenecho $x is presentbreakfiif [[ $i -eq $len1 ]]then echo $x is not presentfii=$(( $i + 1))done