基础值太大(错误标记为“08”)bash
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21763449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 09:33:29 来源:igfitidea点击:
Value too great for base (error token is "08") bash
提问by Helfenstein
I have seen on the forum that the problem is that I create octal instead of decimal, but I can't find out where to change my code to solve this.
我在论坛上看到问题是我创建了八进制而不是十进制,但我找不到在哪里更改我的代码来解决这个问题。
This is part of my code:
dd=1234567890aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
ddate=$(exiv2 "${i}"|grep timestamp)
SPEC=$ddate
read X X YEAR MONTH DAY HOUR MINUTE SECOND <<<${SPEC//:/ }
d1=${YEAR:2}
d2=${dd:(MONTH-1):1}
d3=${dd:(DAY-1):1}
d4=${dd:(HOUR-1):1}
d5=${dd:(MINUTE-1):1}
d6=${dd:(SECOND-1):1}
d7=0
Thank you for the help!
感谢您的帮助!
回答by glenn Hymanman
Tell bash that your variables are decimal, not octal
告诉 bash 你的变量是十进制的,而不是八进制的
d2=${dd:(10#$MONTH-1):1}
d3=${dd:(10#$DAY-1):1}
d4=${dd:(10#$HOUR-1):1}
d5=${dd:(10#$MINUTE-1):1}
d6=${dd:(10#$SECOND-1):1}