New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if bc command is available #1201
Conversation
Thank you, it looks good! |
echo " : --- Memory, CPU info ---- " | ||
mem=$( grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024^2" | bc ) | ||
echo "System memory (GB): ${mem}" | ||
if [ -n "$(command -v bc)" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, i have always used which
, but i guess command
is a more recommended way? (saw a comment about it, but don't have an authoritative source). Either works. Why do you use -v
though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know which of the commands would be better. I don't know which
and i get command -v
from an stackoverflow answer.
But i can verfiy that -v
is good because it displays only the path of the program or blank. Without -v
it displays an explanation of the program, which needs more time to display and it can happen that a program has no description, so it would be return blank too.
Results evaluating commit b68f70a (merged with base d205f4a as a19dfc8). See run details. PostgreSQL DB size in MB: 2792 ⇒ 2791 (-0.0% change)
expand for details...
|
On some systems the
bc
command is not installed, so I added a check if the command can be used.It is a simply calculation from KB to GB. If
bc
is missing, then it is displayed in KB.fix: #1151