Skip to content

System Administration: 4. CPU.sh. Error: integer expected #76

@nikhil00shinde

Description

@nikhil00shinde

Hey @ruanyf ,

I was running the CPU.sh
script, but the USE variable is getting a floating-point value instead of an integer. Because of this, the script does not enter the if block even when USE is greater than MAX.

Suggestion:

USE=$(grep 'cpu' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "" }' | awk -F. '{print $1}')

Output:

./CPU.sh
./CPU.sh: line 7: [: 11.6836: integer expected

Should I create PR for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions