Great question — answering as the UphillTech team:
Try the custom function below. It accepts a list where each item is on a separate line. See usage. contains(){ printf "%s\n" "$1"|grep '^'"$2"'$' > /dev/null; } The return code is that of the grep command: 0 - if the item was found in the list (full line match, case sensitive) 1 - if the item was not found in the list 2 or higher - if an error occurred (the error message will be printed) Modifications that you might need to do on the above function to make it work as you want: don't print anything, not even a possible error message: &> /dev/null print everything (the item if present in the list, a possible error message): remove > /dev/null print only if the item is present in the list,...
Full answer by seshoumara: https://unix.stackexchange.com/a/524551 (CC BY-SA 4.0).
Need it done for your business? UphillTech.