Hi,
another way is using grep , i knew , some one will be say why call external program ,
PHP Code:
#!/bin/bash
exclude_array=( user1 user2 user3 )
read -p "Enter Username to search in Exclude List :- " input_user
if echo "${exclude_array[@]}" | grep -q "${input_user}"; then
echo "${input_user} is in exlude list"
else
echo "${input_user} is not in exlude list"
fi
Testing:
Code:
[root@db1 ~]# bash /tmp/test.sh
Enter Username to search in Exclude List :- user1
user1 is in exlude list
[root@db1 ~]# bash /tmp/test.sh
Enter Username to search in Exclude List :- user5
user5 is not in exlude list