“找不到免费命令";使用git bash运行bash脚本时 [英] "free command not found" while running bash script using git bash

查看:92
本文介绍了“找不到免费命令";使用git bash运行bash脚本时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to display server load, disk space, usage and memory usage in bash script.

但是当我尝试

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 运行脚本,它给了我错误:

this and run the script using ./test.sh it gives me the error:

找不到免费命令

推荐答案

for debian/ubuntu.只需运行

for debian /ubuntu . just run

apt-get install procps 

对于centos

yum install procps

procps包括free,top等linux base commond

the procps include free , top etc linux base commond

这篇关于“找不到免费命令";使用git bash运行bash脚本时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆