Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- mapfile -t lines < <(grep '%Cpu*' 'top-output.txt' | tr -s ' ' -| cut
- -d "-" -f 2) # Aquí obtengo los datos en el array lines
- echo ${lines[@]} # Aquí imprimo los datos y obtengo el resultado
- sum=$(IFS="+"; bc <<< "${lines[*]}" ) # El Syntax Error me da al hacer esto
- echo $sum
- mapfile -t lines < <(grep '%Cpu*' 'top-output.txt' | tr -s ' ' -| cut -
- d "-" -f 2 |tr -s ',' .)
- grep -Eo '[0-9]+(,[0-9]+)?' fichero | tr ',' '.' | awk '{suma += $1} END {print suma+0}'
- $ cat fichero
- 25,3 24,9
- 24,5
- $ grep -Eo '[0-9]+(,[0-9]+)?' fichero
- 25,3
- 24,9
- 24,5
- $ grep -Eo '[0-9]+(,[0-9]+)?' fichero | tr ',' '.'
- 25.3
- 24.9
- 24.5
- $ grep -Eo '[0-9]+(,[0-9]+)?' fichero | tr ',' '.' | awk '{sum+=$1} END {print sum+0}'
- 74.7
Add Comment
Please, Sign In to add comment