i'm having trouble with if in bash. basically i'm trying to do this in bash:
if ((x='r')&&(y='s'))||((x='s')&&(y='p')) then
echo "bluh"
but i've just can't find the proper way, used square brackets, 2 square brackets, round brackets.
but it just won't work...
(( ))
are for bash arithmetic , instead you need [[ ]]
bash test :
if [[ ( $x == r && $y == s ) || ( $x == s && $y == p ) ]]; then
echo "bluh"
fi
[[
is a bash keyword similar to (but more powerful than) the [
command. See http://mywiki.wooledge.org/BashFAQ/031 and http://mywiki.wooledge.org/BashGuide/TestsAndConditionals . Unless you're writing for POSIX sh, we recommend [[
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.