#3 Re: BASH: Buscar texto dentro de archivos
Hola,
Genial el script, tanto, que se me ha ocurrido preguntarte...
Verás, estoy intentando aprender bash y bueno, después de leerme un tutorial, más bien pobre sobre el tema me he lanzado a escribir uno para agregar repositorios, es decir, que busque los que ya estan y los compare con los que yo le escribo y agrege los que no esten, además que comente los descomentados...je, no sé si es demasiado para empezar pero me encanta liarme con estas cosas...
Hasta ahora he hecho esto(de momento lo hago con un fichero de mi escritorio, cambiaré las rutas cuando esté listo el script):
#!/bin/sh
sources=`cat /home/$USER/Escritorio/sources.txt`
grep -r "$sources" deb\ http://packages.medibuntu.org/\ hardy\ free\ non-free"\n"deb\ http://apt.wicd.net\ hardy\ extras"\n"deb\ http://apt.last.fm/\ debian\ stable"\n"deb\ http://download.virtualbox.org/virtualbox/debian\ intrepid\ non-free"\n"#Gráfica\ intel"\n"deb\ http://ppa.launchpad.net/siretart/ppa/ubuntu\ jaunty\ main"\n"deb-src\ http://ppa.launchpad.net/siretart/ppa/ubuntu\ jaunty\ main"\n"#Webmin"\n"deb\ http://download.webmin.com/download/repository\ sarge\ contrib"\n"#Chrome"\n"deb\ http://ppa.launchpad.net/chromium-daily/ppa/ubuntu\ jaunty\ main"\n"deb-src\ http://ppa.launchpad.net/chromium-daily/ppa/ubuntu\ jaunty\ main
echo "deb http://packages.medibuntu.org/ hardy free non-free""\n""deb http://apt.wicd.net hardy extras""\n""deb http://apt.last.fm/ debian stable""\n""deb http://download.virtualbox.org/virtualbox/debian intrepid non-free""\n""#Gráfica intel""\n""deb http://ppa.launchpad.net/siretart/ppa/ubuntu jaunty main""\n""deb-src http://ppa.launchpad.net/siretart/ppa/ubuntu jaunty main""\n""#Webmin""\n""deb http://download.webmin.com/download/repository sarge contrib""\n""#Chrome""\n""deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main""\n""deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu jaunty main" >> /home/$USER/Escritorio/sources.txt
echo
echo "NUEVOS REPOSITORIOS AÑADIDOS"
echo
#Fin del script...
Je, sé que me queda mucho por recorrer, aquí estoy bloqueado, no sé cómo juntarlo, supongo que con un test y un if? en fin, si me puedes dar algún consejillo sobre qué sería interesante aprender o algún tutorial bueno, pues yo agradecido, y si no pues agradecido igualmente.
Un saludo.