I tried to use regex to do a pattern matching for CPU % usage. i only need the value, 0.0.
The command i use:
The result:Code:top -bn1 | grep "Cpu(s)" | grep ".\.." | grep ".\..%us"
After some time, i managed to get the right regex for the pattern matching but its not work in my server.Code:Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
The error prompt out:
Any way i can solve this?Code:top -bn1 | grep \d.\d(?=%us) -bash: syntax error near unexpected token `('