#!/bin/bash variable=`ls` function _declare_borrar_db(){ * find * -name "*.db" -exec rm -rfv {} \; } function _declare_ordenar_url(){ local dirtemp=$1 if [ -f $dirtemp/url ]; then sort $dirtemp/url | uniq >> $dirtemp/fichero mv -v $dirtemp/fichero $dirtemp/domains fi } function _declare_url(){ for i in $variable; do local temp="$i" _declare_ordenar_url $temp if [ -f $i/urls ]; then head -n 1 $i/urls > $i/fichero tail -n +2 $i/urls > $i/fichero_temp sed -i -r -e "s/^/+/" $i/fichero_temp mv -v $i/fichero $i/urls if [ -f $i/urls.diff ]; then cat $i/fichero_temp >> $i/urls.diff else cat $i/fichero_temp > $i/urls.diff fi rm -rfv $i/fichero_temp fi done } function _declare_borrar(){ local dirtemp=$1 rm -rfv $dirtemp } function _declare_ordenar() { local dirtemp=$1 sort $dirtemp/domains | uniq >> $dirtemp/fichero mv -v $dirtemp/fichero $dirtemp/domains } function _declare_domain() { for i in $variable; do if [ -d $i ] && [ $i == porn ] ; then for j in part1 part2 part3 part4 part5; do tmp="$i/porn_$j" _declare_ordenar $tmp head -n 1 $i/porn_$j/domains > $i/porn_$j/domains_temp tail -n +2 $i/porn_$j/domains >> $i/domains.diff mv -v $i/porn_$j/domains_temp $i/porn_$j/domains cat $i/porn_$j/domains>>$i/domains _declare_borrar $tmp done fi if [ $i == porn ]; then head -n 1 $i/domains > $i/fichero tail -n +2 $i/domains > $i/fichero_temp sed -i -r -e "s/^/+/" $i/fichero_temp sed -i -r -e "s/^/+/" $i/domains.diff cat $i/fichero_temp >> $i/domains.diff mv -v $i/fichero $i/domains rm -rfv $i/fichero_temp else _declare_ordenar $i head -n 1 $i/domains > $i/fichero tail -n +2 $i/domains > $i/fichero_temp mv -v $i/fichero $i/domains sed -i -r -e "s/^/+/" $i/fichero_temp if [ -f $i/domains.diff ]; then cat $i/fichero_temp >> $i/domains.diff else mv -v $i/fichero_temp $i/domains.diff fi fi done ##sort fichero | uniq >> fichero2 ##mv -v fichero2 fichero ##sed -i -r -e "s/^/+/" fichero ##mv -v fichero domains.diff } _declare_domain _declare_url _declare_borrar_db
jueves, 26 de septiembre de 2013
script_bash_busqueda_eliminación
Suscribirse a:
Enviar comentarios (Atom)
1 comentario:
Perdon mi ignorancia pero este scrip que busca o que elimina saludos ( mi pregunta es para aprender )
Publicar un comentario