Código
#!/bin/bash if [ $# -ne 2 ] ; then echo -e "Uso: $0 BASE-DATOS CADENA" exit 0 fi BD="$1" CADENA="$2" MYSQLPASS=`cat /etc/mysql_root_pass` LISTATABLAS=`mysql -p$MYSQLPASS $BD -e "show tables;" | grep -iv "tables_in_$BD"` for TABLE in $LISTATABLAS ; do LISTACOLUMNAS=`mysql -p$MYSQLPASS $BD -e "show columns from $TABLE;" | awk '{print $1}' | grep -v "Field"` echo "Buscando \"$CADENA\" en la tabla \"$TABLE\":" for COLUMNA in $LISTACOLUMNAS ; do mysql -p$MYSQLPASS $BD -e "select * from \`$TABLE\` where \`$COLUMNA\` like '%$CADENA%';" done done