In my bash
script I have a string containing a hexadecimal number, e.g. hex="0x12345678"
. Is it possible to treat it as a hex number and do bit shifting on it?
相关问题
- How to get the return code of a shell script in lu
- JQ: Select when attribute value exists in a bash a
- Invoking Mirth Connect CLI with Powershell script
- Emacs shell: save commit message
- bash print whole line after splitting line with if
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- Why does popen() invoke a shell to execute a proce
- In IntelliJ IDEA, how can I create a key binding t
- Check if directory exists on remote machine with s
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- Reverse four length of letters with sed in unix
- Launch interactive SSH bash session from PHP
You can easily bitshift such numbers in an arithmetic context:
Yes.
Arithmetic expressions support base 16 numbers and all the usual
C
operators.Example:
Of course you can do bitwise operations (inside an Arithmetic Expansion):
Or:
The value could be set in a variable as well:
And you can do OR, AND and XOR:
And to get the result in hex as well: