sergio_educacionit

suma memoria

Aug 8th, 2026 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. memoria_total () {
  2.  
  3. local num_1=$1
  4. local num_2=$2
  5. echo $(($num_1+$num_2))
  6.  
  7. }
  8.  
  9.  
  10. # primer numero
  11. memoria_fisica=$(free | awk '/^Mem:/ {print $3}')
  12.  
  13. # segundo numero
  14. memoria_intercambio=$(free | awk '/^Inter:/ {print $3}')
  15.  
  16. # kilobytes
  17. resultado=$(suma_numeros $memoria_fisica $memoria_intercambio)
  18. # megabytes
  19. resultado=$((resultado/1024))
  20.  
  21. echo "Memoria total utilizada (fisica y de intercambio): ${resultado}MB"
  22.  
  23.  
  24. cat /etc/* > /dev/null
  25. # primer numero
  26. memoria_fisica=$(free | awk '/^Mem:/ {print $3}')
  27.  
  28. # segundo numero
  29. memoria_intercambio=$(free | awk '/^Inter:/ {print $3}')
  30.  
  31. # kilobytes
  32. resultado=$(memoria_total $memoria_fisica $memoria_intercambio)
  33. # megabytes
  34. resultado=$((resultado/1024))
  35.  
  36. echo "Memoria total utilizada (fisica y de intercambio): ${resultado}MB"
Advertisement
Add Comment
Please, Sign In to add comment