Guest User

Untitled

a guest
Mar 6th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #!/bin/bash
  2. mapfile -t lines < <(grep '%Cpu*' 'top-output.txt' | tr -s ' ' -| cut
  3. -d "-" -f 2) # Aquí obtengo los datos en el array lines
  4. echo ${lines[@]} # Aquí imprimo los datos y obtengo el resultado
  5.  
  6. sum=$(IFS="+"; bc <<< "${lines[*]}" ) # El Syntax Error me da al hacer esto
  7. echo $sum
  8.  
  9. mapfile -t lines < <(grep '%Cpu*' 'top-output.txt' | tr -s ' ' -| cut -
  10. d "-" -f 2 |tr -s ',' .)
  11.  
  12. grep -Eo '[0-9]+(,[0-9]+)?' fichero | tr ',' '.' | awk '{suma += $1} END {print suma+0}'
  13.  
  14. $ cat fichero
  15. 25,3 24,9
  16. 24,5
  17. $ grep -Eo '[0-9]+(,[0-9]+)?' fichero
  18. 25,3
  19. 24,9
  20. 24,5
  21. $ grep -Eo '[0-9]+(,[0-9]+)?' fichero | tr ',' '.'
  22. 25.3
  23. 24.9
  24. 24.5
  25. $ grep -Eo '[0-9]+(,[0-9]+)?' fichero | tr ',' '.' | awk '{sum+=$1} END {print sum+0}'
  26. 74.7
Add Comment
Please, Sign In to add comment