specify numeric locale for parsing top output

This commit is contained in:
Gaganpreet 2020-08-31 11:41:45 +02:00
parent fbc02789b4
commit 33703eb2d3

View file

@ -4,7 +4,7 @@ get_percent()
{
case $(uname -s) in
Linux)
percent=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
percent=$(LC_NUMERIC=en_US.UTF-8 top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
echo $percent
;;