繁体   English   中英

意外参数 expr 和 MemTotal

[英]Unexpected Argument expr & MemTotal

试图让这个小的 bash 脚本工作,我目前收到这个错误:

不确定我的语法问题在哪里。

expr: syntax error: unexpected argument ‘32489356’
Your System RAM is: $RAM_GB GB and that meets the minimum requirements for Docker Desktop.
#!/bin/bash
CURRENT_TIME="$(date +"%x %r %Z")"
TIMESTAMP="Generated $CURRENT_TIME, by $USER"
echo $TIMESTAMP


check_ram () {
  RAM_KB=$(grep MemTotal /proc/meminfo)
  RAM_GB=$(expr $RAM_KB / 1000000)
  if ($RAM_GB > 4); then
  echo 'Your System RAM is: $RAM_GB GB and that meets the minimum requirements for Docker Desktop.'
  else
  echo 'Your computer does not meet the minimum RAM requirements.'
  exit 0
  fi
  return
}

这是一个修复

#!/bin/bash
CURRENT_TIME="$(date +"%x %r %Z")"
TIMESTAMP="Generated $CURRENT_TIME, by $USER"
echo $TIMESTAMP

check_ram () {
RAM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')
RAM_GB=$(expr $RAM_KB / 1000000)
if [ $RAM_GB -gt 4 ]; then
echo "Your System RAM is: $RAM_GB GB and that meets the minimum requirements for Docker Desktop."
else
echo "Your computer does not meet the minimum RAM requirements."
exit 0
fi
return
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM