9
rated 0 times
[
9]
[
0]
/ answers: 1 / hits: 86381
/ 3 Years ago, sat, august 7, 2021, 7:24:42
I have a Bash shell function that takes an argument and performs something on it if needed.
do_something() {
if [need to do something on $1]
then
do it
return 0
else
return 1
fi
}
I want to call this method with several arguments and check if at least one of them succeeded.
I tried something like:
if [ do_something "arg1" ||
do_something "arg2" ||
do_something "arg3" ]
then
echo "OK"
else
echo "NOT OK"
fi
Also, I want to make sure that even if the first condition is true all other conditions will still be evaluated.
What is the correct syntax for that?
More From » bash