如何在外壳中将十六进制数与十六进制数进行比较? [英] How to compare hexadecimal numbers with hexadecimal numbers in shell?

查看:74
本文介绍了如何在外壳中将十六进制数与十六进制数进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to compare hexadecimal number with hexadecimal numbers in shell?

推荐答案

至少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...

这篇关于如何在外壳中将十六进制数与十六进制数进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆