Eston son algunos de los scripts que uso a diario, bueno, no a diarion, pero son de uso personal, los dejo para ver si a alguien le sirven, que los prueben y vean qué modificaciones se les puede hacer.
space
#!/bin/bash
# Leo Gutiérrez R. leorocko13@hotmail.com
# Script que comprime todos los archivos en el directorio actual.
# Util para hacer espacio en dispositivos extraíbles.
# Uso personal.
find . -type f | while read file
do
extension=`echo "${file}" | awk -F . '{print $NF}'`;
echo -e "$extension" | grep -ie "^\(rar\|Z\|7z\|bz2\|zip\|gz\)$" &> /dev/null && continue;
rar a "${file}.rar" "$file" -y -df
done
usb
#!/bin/bash
# Leo Gutiérrez R.
# Script para navegar por sobre los dispositivos USB en el sistema.
# Uso personal.
select archivo in `ls -1 /media/ | grep -v "^cd$" | grep -v "^dvd$" | grep -v "^fl$" | grep -v "^ubuntu$" | grep -v "^windows$"`
do
if [ -n "$archivo" ]
then
cd /media/"$archivo"
break;
else
echo -e "Error eligiendo dispositivo";
exit 1;
fi
done
cdprompt
[leo@archero ~]$ cdprompt
1) amsn_received/ 9) drivers_tia_de_valeria/ 17) Musica/ 25) Software/
2) bash/ 10) escuela/ 18) NetBeansProjects/ 26) Textos/
3) cpps/ 11) guitar/ 19) perl/ 27) visual/
4) c_proyects/ 12) Imagenes/ 20) projects/ 28) yare/
5) Descargas/ 13) java/ 21) proyectos/ 29) SALIR
6) Desktop/ 14) linux/ 22) python/
7) Downloads/ 15) maiesecuele/ 23) respaldo_usb_papa/
8) drivers_cesar/ 16) *****/ 24) revistas/
>
#!/bin/bash -
#===============================================================================
#
# FILE: cdprompt.sh
#
# USAGE: ./cdprompt.sh
#
# DESCRIPTION: Cambio de directorios interactivamente.
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: |Leo Gutiérrez R.| (), |leorocko13@hotmail|
# COMPANY:
# CREATED: 02/26/2011 01:51:28 AM CST
# REVISION: ---
#===============================================================================
select directorio in */ "SALIR"
do
if [ "$directorio" = "SALIR" ]
then
break;
elif [[ -n "$directorio" ]]
then
cd "$directorio"
break;
else
echo -e "\aError de opción.";
break;
fi
done
rmsecure
Script de borrado interactivo, muestra qué archivos eliminar en el directorio local:
1) C_Plus_Plus_Varios_Libros.rar 5) PKGBUILD
2) Diagrama_EDGAR.mwb 6) src
3) pacman-3.5.1 7) SALIR
4) pacman-3.5.1.tar.gz
>
#!/bin/bash
# Script de borrado interactivo.
# Leo Gutiérrez Ramírez. leorocko13@hotmail.com
function rmsecure()
{
select archivos in * "SALIR"
do
if [ "${archivos}" = "SALIR" ]
then
exit 0;
elif [[ -n "${archivos}" ]]
then
sudo rm -rvi "${archivos}" || {
echo -e "Error borrando archivo : ${archivos}";
exit 0;
}
clear;
rmsecure;
else
echo -e "Error eligiendo archivo.";
fi
done
}
clear;
rmsecure;
unins.sh
Script para ArchLinux, muestra los paquetes para elegir cuál desinstalar, todo a través de una pequeña interfaz.
(http://img715.imageshack.us/img715/6595/unled1x.jpg)
#!/bin/bash
[ ${UID} != 0 ] && {
echo -e "Se requieren privilegios de Root";
exit 1;
}
pacman -Qei | sed -n "s/^Name.*\:\s\(.*\)/\1/p" > nombres.txt
pacman -Qei | sed -n "s/^Version.*\:\s\(.*\)/\1/p" > versiones.txt
Xdialog --title "Desinstalar paquetes" --menu "Elija su paquete:" 24 51 6 $(paste nombres.txt versiones.txt) 2> /tmp/menu.tmp.$$
retval=$?
choice=`cat /tmp/menu.tmp.$$`
rm -f nombres.txt
rm -f versiones.txt
rm -f /tmp/menu.tmp.$$
case "$retval" in
1)
exit 0;
;;
255)
exit 0;
;;
esac
yes | pacman -R "${choice}" && {
Xdialog --title "Desinatalar paquetes" --msgbox "${choice} desinstalado con éxito." 10 100
} || {
Xdialog --title "Desinatalar paquetes" --msgbox "${choice} no se pudo desinstalar." 10 100
exit 1;
}
exit 0;
sc
#!/bin/bash
# Leo Gutiérrez R.
# Script para comprobar si un proceso está corriendo.
[ $# -ne 1 ] && {
cat <<EOF
`basename $0` service
EOF
exit 1;
}
[ -f "/var/run/daemons/$1" ] && {
echo -e "\"$1\" running.";
} || {
echo -e "\"$1\" stopped.";
}
exit 0;
modins
#!/bin/bash
# Script para instalar paquetes en Perl.
function getch()
{
OLD_STTY=`stty -g`
stty cbreak -echo
look=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
stty $OLD_STTY
}
function installModule()
{
sudo perl Makefile.PL
sudo make
sudo make test
sudo make install
}
function modins()
{
archivo=
select archivo in *.tar.gz "SALIR"
do
if [ "${archivo}" = "SALIR" ]
then
exit 0;
elif [[ -n "${archivo}" ]]
then
echo -e "Elegiste : ${archivo}";
tar zxvf "${archivo}" &> /dev/null || {
echo -e "Error descomprimiendo [ ${archivo} ]";
exit 1;
}
cd "${archivo%\.tar.gz}" 2> /dev/null || {
echo -e "\aError abriendo directorio ${archivo%%.*}";
exit 1;
}
installModule;
echo -e "\E[31;47mMódulo instalado. Presione una tecla para continuar.";
tput sgr0;
getch;
break;
else
echo -e "Error eligiendo archivo.";
exit 0;
fi
done
}
modins;
exit 0;
Saludos.
Muy buen aporte, si señor!
Te pongo aqui los que yo uso, solo son 2, pero espero que ayuden a alguien :P
Script cambiar de fondo pantalla cada 15 minutos
#!/bin/sh
#Script para cambiar de fondo de escritorio cada 10 minutos
cd ~/Imagenes/Fondos\ pantalla/
while [ 1 ]; do
for aux in $(ls) ; do
#echo "gconftool-2 --type string --set /desktop/gnome/background/picture_filename ~/Imagenes/Fondos\ pantalla/$aux"
sleep 15m
gconftool-2 --type string --set /desktop/gnome/background/picture_filename ~/Imagenes/Fondos\ pantalla/$aux
done
done
wait
Script para abrir JDownloader (Yo lo uso como aplicacion al inicio)
#!/bin/sh
#Cambiar por el directorio donde tengais el JDownloader.jar
echo "Ejecuntando JDownloader..."
nohup java -jar /home/java/Escritorio/JDownloader/JDownloader.jar
& exit
Además, uso otro script que me ejecuta un terminal en mitad de la pantalla transparente al iniciar sesión que queda bastante bien, si os interesa decidmelo xD
Os pongo una imagen:
(http://img842.imageshack.us/img842/3352/mipantallaf.png)
Un saludo!
#!/usr/bin/env bash
# Script para extraer archivos
# JuszR gentoo@rocks.net
# GPL
if [ "$#" -lt 1 ]; then
echo -ne "\n\tUso:"
echo -e "\n\t$(basename $0) <archivo> (.tar, .rar, .bz2...)"
echo ""
exit 1
fi
if [ -f $1 ] ; then
case $1 in
*.tar.bz2 | *.tbz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' no puede ser extraido" ;;
esac
else
echo "'$1' no es un archivo valido"
fi
#!/usr/bin/env bash
# Colores en bash
# JuszR gentoo@rocks.net
# GPL
# Variables
txtund=$(tput sgr 0 1) # Subrayado
txtbld=$(tput bold) # Negrita
bldred=${txtbld}$(tput setaf 1) # rojo
bldblu=${txtbld}$(tput setaf 4) # azul
bldwht=${txtbld}$(tput setaf 7) # blanco
txtrst=$(tput sgr0) # Resetear
info=${bldwht}*${txtrst} # Feedback
pass=${bldblu}*${txtrst}
warn=${bldred}!${txtrst}
echo
echo -e "$(tput bold) norm negr subr tput-colores$(tput sgr0)"
for i in $(seq 1 7); do
echo " $(tput setaf $i)Texto$(tput sgr0) $(tput bold)$(tput setaf $i)Texto$(tput sgr0) $(tput sgr 0 1)$(tput setaf $i)Texto$(tput sgr0) \$(tput setaf $i)"
done
echo ' Negrita $(tput bold)'
echo ' Subrayado $(tput sgr 0 1)'