informatica:linux:bash
This is an old revision of the document!
Table of Contents
bash
bash
Sumar decimales
# bash no entiende de tipos a="1.23" b="4.567" c=`echo $a * $b | bc` echo $c
Tráfico de red (mejorar)
/usr/bin/bashcalc.sh
#!/bin/bash echo "scale=4; $1" | bc ;exit
Falta por cambiar 'eth0' por $Interfaz
#!/bin/bash # OJO: requiere de /usr/bin/bashcalc.sh Interfaz="eth1" Segundos=10 Bytes_inicio=`awk -F'[: ]*' '/eth0/{print $11}' < /proc/net/dev` sleep $Segundos Bytes_fin=`awk -F'[: ]*' '/eth0/{print $11}' < /proc/net/dev` echo "Bytes_inicio: "$Bytes_inicio echo "Bytes_fin: "$Bytes_fin Resta=`echo $Bytes_fin - $Bytes_inicio | bc` echo "Resta: "$Resta # NO funciona #Final=`echo $Resta/1024 | bc` # Chapuza Final=`/usr/bin/bashcalc.sh $Resta/1024/$Segundos` echo "Resultado: "$Final" Kb/s en interfaz "$Interfaz
informatica/linux/bash.1263026505.txt.gz · Last modified: 2015/04/13 20:19 (external edit)