#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    162
    Rep Power
    62

    Bitwise in Bash Scripting?


    g'Afternoon,
    I'm trying to use bitwise in a bash script I'm writing, but it's producing some odd results

    if I do an 'echo $((11000000 & 11111111))'
    It returns with '10586304', which is not the integer, nor is it the binary result. What am I missing for bitwise operations in bash?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    162
    Rep Power
    62
    Turns out it was a PEBKAC error.

    Did not read up on the bitwise operator, just assumed it expected binary data. If I give in the proper integer, it works great lol.

    Instead of $((11000000 & 11111111)), I should have used $((192 & 255))

IMN logo majestic logo threadwatch logo seochat tools logo