How to use bitwise operators in if statements?

前端 未结 3 757
迷失自我
迷失自我 2021-02-07 08:33

I want to write something like this:

if [[ ( releases[\"token\"] & $MASK ) -eq 1 ]]; then

but I get the error that:

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-07 09:03

    You can use Arithmetic Expansion:

    (((5&3)==1)) && echo YES || echo NO
    

    It will print YES

提交回复
热议问题