Files
bash-programming-from-scratch/manuscript/resources/code/BashScripting/for-break.sh
2020-10-17 10:22:39 +02:00

21 lines
362 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
array=(Alice Bob Eve Mallory)
is_found="0"
for element in "${array[@]}"
do
if [[ "$element" == "$1" ]]
then
is_found="1"
break
fi
done
if [[ "$is_found" -ne "0" ]]
then
echo "Элемент со значением $1 есть в массиве"
else
echo "Элемента со значением $1 нет в массиве"
fi