[eside-ghost] Bash Scripting: buscar string entre 2 patrones

AngelD angeld en froga.net
Lun Mar 29 13:35:10 CEST 2010


	Si he entendido bien, lo que quieres es el nombre de fichero
sin extensión. Se puede realizar de muchas maneras, pero así, rápido,
con 'cut' y usando como delimitador el punto:

	$ echo "xxxxxx.h" |cut -d "." -f1
	 xxxxxx


El Mon, 29 Mar 2010 12:07:02 +0100
NoxWings <18dagarc en gmail.com> escribió:

> Aupa
> 
> Estoy haciendo un pequeño script para generar mis propios makefiles
> (acabo de empezar con bash scripting), y estoy atascado intentando
> obtener los includes de los ficheros fuente. Por el momento he hecho
> esta función:
> 
> *function searchIncludes*
> *{*
> * **if [ -e $1 ]; then*
> * **INCLUDE="#include"*
> * **FOUND=0*
> * **for i in `cat $1`; do*
> * **if [ $i = $INCLUDE ]; then*
> * **let** **FOUND=1*
> * **elif [ $FOUND -eq 1 ]; then*
> * **echo -e "$i \c"  # aqui obtener el string entre " y .h*
> * **let FOUND=0*
> * **fi*
> * **done*
> * **fi*
> *}*
> *
> *
> *$ searchIncludes scene.hpp*
> *<Ogre.h> <OgreFrameListener.h> "input.hpp" "debug.hpp"*
> 
> Pero no consigo encontrar un comando para mostrar solo por pantalla el
> string que se encuentra entre la primera comilla y el ".h"
> de tal forma que la salida obtenida fuese:
> *input debug*
> *
> *
> *¿Alguna ayuda? *
> *Gracias*
> *
> *
> *David GM*


Más información sobre la lista de distribución eside-ghost