That day to write a script, you need to turn the hexadecimal number into a decimal, found do not know how to do, search, the original is very simple, than with C language or something easier, on some ready-made orders to solve.
Two simple methods are listed first:
1) Echo can achieve it by itself, quite simply. However, you do not know what to write if you want to convert from decimal to hexadecimal.
]$ echo $ ((0XAC))
172
2) printf can also oh, hexadecimal and decimal conversions are fine.
]$ printf%d 0xac
172
]$ printf%x 172
Ac
Then, a little bit more trouble is the BC command. Although the online introduction of a lot of people, but in the end BC of those two parameters is how to use, or do not quite understand, feel oneself is also from the results to push the reason, do not really understand the parameters of this command so the meaning of design. In any case, let's write an example here and study it in the future.
3) BC role: 16 binary and decimal reciprocal, between decimal and binary can also be converted.
Convert 16 binary to decimal
]$ Echo ' ibase=16;obase=a; AC ' |BC
172
]$ Echo ' ibase=16;obase=1010; AC ' |BC (Linux)
0172
> Echo ' ibase=16;obase=1010; AC ' |BC (Unix)
Output base is too large
172
Note here: This error will be reported when executing in Unix, but there will still be results.
]$ Echo ' ibase=16; AC ' | Bc
172
Convert decimal to hexadecimal
]$ echo ' ibase=10;obase=16;172 ' |BC
AC
]$ echo ' obase=16;172 ' |BC
AC
converting decimal to Binary
]$ echo ' obase=2;172 ' |BC
10101100
Convert binary into decimal
]$ echo ' ibase=2;10101100 ' |BC
172
Looks like IBase and obase the default value of the two parameters is 10 (decimal), so it seems that if you do not write, IBase represents the input parameter is decimal, Obase represents the value of the output is decimal. In other words, it is not a decimal time to indicate, it seems that this will not be wrong.
Well, study again.
Http://blog.sina.com.cn/s/blog_a3052b4a0100z4nk.html
Convert 16 binary to decimal (turn) with Linux/unix command