samedi 14 septembre 2019

Bash IF check exact number is in the list

I want to check if the number is in the list, but 23369 is matched with 2336953. I would like to know to match only exact number using IF in bash.

cgroup_uid="1251243 2007297 2336953 695212 834248 23369"
run_uid="1251243 2007297 2336953 695212 834248"
echo $cgroup_uid
echo $run_uid

for i in $cgroup_uid;do
if [[ $run_uid =~ $i ]]; then
    echo "contains $i"
fi
done

I would appreciate any advice.

Aucun commentaire:

Enregistrer un commentaire