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
Colorear archivos
1. Instalar vim
sudo aptitude update && sudo aptitude install vim
2. Crear archivo:
vim /home/miusuario/.vimrc
Con el siguiente contenido:
:syntax on
3. Grabar y salir
informatica/linux/bash.1271270902.txt.gz · Last modified: (external edit)
