gpt4 book ai didi

shell # 里面 (( ))

转载 作者:行者123 更新时间:2023-12-04 06:04:40 26 4
gpt4 key购买 nike

我是 shell 的新手。我不太了解以下功能。这个函数基本上把小时加1。

我想知道为什么开发人员在 $g_current_hour+1 前面放了“10#”。根据我的理解,shell 中的剂量 # 是指注释吗?

f_increment_hour() {
g_next_hour=$((10#$g_current_hour+1))
}

最佳答案

一切都取决于上下文。这里10#表示基数为 10。

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.

关于 shell # 里面 (( )),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8503856/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com