User Tools

Site Tools


informatica:linux:bash

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
informatica:linux:bash [2010/01/09 08:24] 192.168.1.30informatica:linux:bash [2015/04/13 20:19] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 ====== bash ====== ====== bash ======
 +
 +
  
  
Line 10: Line 12:
 a="1.23" a="1.23"
 b="4.567" b="4.567"
-c=`echo $a * $b | bc `+c=`echo $a * $b | bc`
 echo $c echo $c
 </code> </code>
 +
 +===== Tráfico de red (mejorar) =====
 +
 +/usr/bin/bashcalc.sh
 +
 +<code>
 +#!/bin/bash
 +echo "scale=4; $1" | bc ;exit
 +</code>
 +
 +Falta por cambiar 'eth0' por $Interfaz
 +
 +<code>
 +#!/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
 +</code>
 +
 +
 +===== 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
 +
 +
 +===== Colorear Línea de Comandos =====
 +
 +echo -en '\033[42m\033[43m'hola`tput sgr0`
 +
 +https://lh3.googleusercontent.com/-c9dZQIsNe-M/UT8f4IqjEbI/AAAAAAAAO9Y/01hoRL6NhXs/s485/bash_colors.png
 +
 +rojo
 +  echo -en '\033[1;37m\033[41m'rojo`tput sgr0`;echo
 +
 +verde
 +  echo -en '\033[1;37m\033[42m'verde`tput sgr0`;echo
 +
 +azul
 +  echo -en '\033[1;37m\033[46m'azul`tput sgr0`;echo
 +
 +
 +===== 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.1263025447.txt.gz · Last modified: 2015/04/13 20:19 (external edit)