Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Hex -> Dec

Options
  • 18-01-2007 5:10pm
    #1
    Registered Users Posts: 2,327 ✭✭✭


    hey,
    I'm trying to pull a mouse's input in linux from dev/input/mice. I'm currently using xxd to do this and I want to convert it to decimal. I've tried doing echo $((0x2dec)) xxd dev/input/mice but it doesn't seem to work. I'm pretty much a complete linux noob so any ideas/suggestions would be helpful.


Comments

  • Registered Users Posts: 6,508 ✭✭✭daymobrew


    Look into 'od' (dump files in octal and other formats).
    I tend to use it to print hex:
    $ od -t x1 /usr/bin/xxd
    0000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
    0000020 02 00 03 00 01 00 00 00 b0 87 04 08 34 00 00 00
    0000040 7c 32 00 00 00 00 00 00 34 00 20 00 07 00 28 00
    0000060 1d 00 1c 00 06 00 00 00 34 00 00 00 34 80 04 08
    0000100 34 80 04 08 e0 00 00 00 e0 00 00 00 05 00 00 00
    
    For unsigned decimal numbers:
    [root@reserv bin]$ od -t u1 /usr/bin/xxd
    0000000 127  69  76  70   1   1   1   0   0   0   0   0   0   0   0   0
    0000020   2   0   3   0   1   0   0   0 176 135   4   8  52   0   0   0
    0000040 124  50   0   0   0   0   0   0  52   0  32   0   7   0  40   0
    0000060  29   0  28   0   6   0   0   0  52   0   0   0  52 128   4   8
    
    It might allow you to read directly from /dev/input/mice.


Advertisement