gpt4 book ai didi

shell - "free command not found"使用 git bash 运行 bash 脚本时

转载 作者:行者123 更新时间:2023-12-04 20:35:22 27 4
gpt4 key购买 nike

我想在 bash 脚本中显示服务器负载、磁盘空间、使用情况和内存使用情况。

但是当我尝试

echo "Memory usage:"
memory_usage=$ free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }'
echo $memory_usage

并使用 ./test.sh 运行脚本它给了我错误:

free command not found

最佳答案

对于 debian/ubuntu 。赶紧跑

apt-get install procps 

对于centos
yum install procps

procps 包括 free 、 top 等 linux base commond

关于shell - "free command not found"使用 git bash 运行 bash 脚本时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36737044/

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