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
Logs
09/05-00:00:03.054 [08] <001 QUEUE>my_server-1.mydomain.com> queue::pollClients: Session 28 (0 Queued 0 Active)
Extraer la cola:
cat log_file.txt | grep "pollClients: Session" | tail -n 1 | awk '{print $9}' | sed "s/^(//"
informatica/linux/bash.1284128239.txt.gz · Last modified: (external edit)
