티스토리 뷰

공부

[Sh] array contains

승가비 2022. 5. 23. 00:20
728x90
if [[ " ${array[*]} " =~ " ${value} " ]]; then
    # whatever you want to do when array contains value
fi

if [[ ! " ${array[*]} " =~ " ${value} " ]]; then
    # whatever you want to do when array doesn't contain value
fi

https://stackoverflow.com/questions/3685970/check-if-a-bash-array-contains-a-value

 

Check if a Bash array contains a value

In Bash, what is the simplest way to test if an array contains a certain value?

stackoverflow.com

 

728x90
댓글
댓글쓰기 폼