echo $ {((2#$ 1)))到底有什么作用?

纳米盘

给定二进制数时,以下bash脚本显示十进制数。

echo $((2#$1))

为什么会这样呢?

我知道这$1是输入。也许2是基数(二进制)。但是我不明白所使用的语法。

Ipor警报器

男子猛击

   echo [-neE] [arg ...]
          Output  the  args,  separated  by spaces, followed by a newline.
          The return status is 0 unless a write error occurs.   If  -n  is
          specified, the trailing newline is suppressed.  If the -e option
          is given,  interpretation  of  the  following  backslash-escaped
          characters  is  enabled.

[...]

   Arithmetic Expansion
       Arithmetic  expansion allows the evaluation of an arithmetic expression
       and the substitution of the result.  The format for  arithmetic  expan‐
       sion is:

              $((expression))

[...]

   Constants with a leading 0 are interpreted as octal numbers.  A leading
   0x or  0X  denotes  hexadecimal.   Otherwise,  numbers  take  the  form
   [base#]n,  where the optional base is a decimal number between 2 and 64
   representing the arithmetic base, and n is a number in that  base.   If
   base#  is omitted, then base 10 is used.  When specifying n, the digits
   greater than 9 are represented by the lowercase letters, the  uppercase
   letters, @, and _, in that order.  If base is less than or equal to 36,
   lowercase and uppercase letters may be used interchangeably  to  repre‐
   sent numbers between 10 and 35.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

maxSwallowSize 到底有什么作用?

比较Integers与==到底有什么作用?

zpool export 到底有什么作用?

Java:NIO和NIO.2之间到底有什么区别?

echo命令有什么作用?

将数组初始化为-1到底有什么作用?

spring.cloud.stream.source 到底有什么作用?

TruncatedSVD get_params([deep]) 到底有什么作用?

`-C`标志在`scp`中到底有什么作用?

“引用”在Delphi中到底有什么作用?

gulp-release-tasks到底有什么作用?

scrollView 中的 fillViewPort 到底有什么作用?

ctypes.cdll.LoadLibrary 到底有什么作用?

试图了解echo $((($ 1 * 2))的语法

echo“”> / dev / null有什么作用?

为什么别名foo1 =“ echo $ 1”和别名foo2 =“ echo'$ 1'”的行为相同?

比较2表之间的mysql ID并显示所有具有匹配ID的echo echo是

#define到底有什么用?

BIOS到底有什么限制?

没有其他选项的“ git update-index -g”到底有什么作用?

使用> / dev / null 2>&1时,“ echo> / sys / ...”无效

在bash脚本中“ cd`echo $ 0 | sed's / \(。* \)\ /.*/ \ 1 /'`有什么作用?

rx-vlan-offload和tx-vlan-offload ethtool选项到底有什么作用?

R8完全模式到底有什么作用(积极的优化)?

“与Windows一起安装”功能到底有什么作用?

这种表达语言$ {pageContext.request.contextPath}在JSP EL中到底有什么作用?

$'text'在Bash中到底有什么作用?可以在Zsh中使用吗?

JavaScript的严格模式对隐式全局声明到底有什么作用?

eclipse命令行参数“ -clean”到底有什么作用?