且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在外壳中将十六进制数与十六进制数进行比较?

更新时间:2023-11-08 11:35:04

至少bash直接支持十六进制整数,只要它们以0x为前缀:

At least bash supports hexadecimal integers directly, provided that they are prefixed with 0x:

$ [[ 0xdead -lt 0xcafe ]] && echo yes || echo no
no
$ [[ 0xdead -gt 0xcafe ]] && echo yes || echo no
yes

您通常只使用比较运算符...

You just use the comparison operators normally...