Reputation: 47
I have a function to which I'm passing, one by one) elements of the array as a arguments. Output of a function is a string. How can I check if output of that function is the same as its argument (element of an array). Something like: if string produced by the function is the same as string from the array (function argument) do something else do something. Simplified cod example:
array=(one two three)
for x in ${array[*]}; do
if [[ -z function $x ]]; then
echo "${x}"
fi
done
Thanks.
EDIT: Corrected description (hopefully it makes more sense now).
Upvotes: 0
Views: 88
Reputation: 189387
Sounds like you want
if [[ "$x" == "$(function "$x")" ]]; then ...
Upvotes: 2