【发布时间】:2016-07-12 23:40:44
【问题描述】:
answer=$(echo $(( length / 1024 )) | bc -l)
所以长度是一个变量,其值类似于2402267538.,需要除以1024。
执行此操作会引发此错误
")syntax error: invalid arithmetic operator (error token is "
【问题讨论】:
-
Your comment here 是由文本中的“回车”字符(Windows 中的行尾)引起的。从变量
length中删除它们以使所有工作正常。可能是这样的:length=${length//[!-0-9]/}
标签: bash shell scripting centos bc