Bash shell中小数为二进制转换 [英] Bash shell Decimal to Binary conversion
本文介绍了Bash shell中小数为二进制转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找在Bash中一个简单的方法,以十进制数转换成二进制数。我有一个需要转换的变量:
I'm looking for an easy way in Bash to convert a decimal number into a binary number. I have variables that need to be converted:
$ip1 $ip2 $ip3 $ip4
有一个简单的方法来做到这一点不看每个人多少?
Is there a simple method to do this without looking at every individual number?
我想preFER不要有写了很多code的。
I would prefer not to have to write a lot of code.
推荐答案
您可以使用 BC
为:
echo "obase=2;$ip1" | bc
这篇关于Bash shell中小数为二进制转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文