Re: Awk Parseo

ricardo gamboa <[email protected]>
Newsgroups gmane.org.user-groups.linux.gulcr
Message-ID <[email protected]>
Hola gente,solo queria hacer un aporte de lo que
llevaba,mmmm,si me pueden hechar una mano,seria de
mucha utilidad :) , gracias!

tarro#cat script.awk

BEGIN {
  FS="<ENT>"
      }
{
   {
   EMPIEZO= match($0,"<ENT>")+5
   FIN=match($0,"</ENT>")
   MIX=FIN-EMPIEZO

   printf substr ($0 ,EMPIEZO ,MIX)
   printf "\n"
  }
}

/* no imprime todas las entidades del file*/

tarro#gawk -f script.awk file
ent1
ent3
tarro#


-ricardo


--- ricardo gamboa <[email protected]> wrote:

> 
> Hola Gente!,Pura vida?
> 
> Queria ver si me podian ayudar como hacer esto con
> un
> script en awk,
> 
> Tengo un archivo plano con una sintaxys tipo XML:
> 
> #cat file
> <SENT>pal1<ENT>ent1</ENT>pal2 pal3 pal4<ENT>ent2
> </ENT></SENT>
> <SENT>pal5 pal6 pal7<ENT>ent3</ENT>pal8 pal9 pal10
> <ENT>ent4</ENT>pal11</SENT> 
> 
> 
> //OJO: Es <SENT> por linea en el archivo ,ese
> archivo
> tiene 2 lineas
> 
> Tiene que obtener todas las entidades(ENT)del
> archivo,
> y mostrar 2 palabras(pal) antes Y 2 palabras despues
> de la entidad.
> 
> #Patron: --Palabra Palabra ENT Palabra Palabra------
> 
> #awk -f script.awk file
> 
> El script deberia devolver esto
>                      pal1 ent1 pal2 pal3
>                 pal3 pal4 ent2
>                 pal6 pal7 ent3 pal8 pal9
>                pal9 pal10 ent4 pal11
> 
> Muchas Gracias y Saludos!, :)
> 
> -ric
> 
> 
>  
>
____________________________________________________________________________________
> Need a quick answer? Get one in minutes from people
> who know.
> Ask your question on www.Answers.yahoo.com
> 
> -- 
> Desuscripción: escriba a
> [email protected], tema 'unsubscribe'
> Problemas a: [email protected]. 
> http://gulcr.org/ListasDeCorreo
> 
> 



 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097

-- 
Desuscripción: escriba a [email protected], tema 'unsubscribe'
Problemas a: [email protected].  http://gulcr.org/ListasDeCorreo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.