[eside-ghost] Peleas con awk
Ramón Echávarri
ramandi en teleline.es
Vie Mar 26 14:21:39 CET 2004
Aupa,
me ha picado la curiosidad con el awk y he estado haciendo algunas pruebas.
Creo que te funcionaría algo así:
#!/bin/sh
FECHA=`awk '/Texto/ {print$6}' fichero`
export FECHA
awk '/TextoInicio/,/TextoFin/' fichero > rdo.txt
awk '{print ENVIRON["FECHA"] " " $0 }' rdo.txt > rdo2.txt
Saludos,
Ramón
----- Original Message -----
From: "DAVID RODRIGUEZ" <dajon en euskalnet.net>
To: <eside-ghost en deusto.es>
Sent: Friday, March 26, 2004 10:31 AM
Subject: [eside-ghost] Peleas con awk
Aupa,
A ver si alguien me puede ayudar:
Tengo dos problemas que no puedo solucionar he leido manuales man webs
y no encuentro la solucion, seguro que es una parida pero no se como
es, os los comentos a ver si alguien lo sabe:
Tengo un documento del cual tengo que seleccionar una parte de el entre
dos puntos que lo hago mediante
awk '/TextoInicio/,/TextoFin/' fichero >> rdo.txt
vale esto sale bien la cosa es que este mismo fichero, en una linea del
mismo tiene la fecha en el cual se inicio el proceso la cual la
encuentro mediante un texto que solo aparece en esa linea y la fecha
esta en el sexto registro, lo hago asi:
awk '/Texto/ {print$6}' fichero
La cosa esque necesito añadir esa fecha delante de cada linea del
fichero rdo.txt y lo he intentado de dos maneras y las dos no funcionan:
#!/bin/ksh
#
FECHA=`awk '/Texto/ {print$6}' fichero`
awk '/TextoInicio/,/TextoFin/' fichero > rdo.txt
awk '{print ${FECHA} " " $0 }' >> rdo.txt
y me da ...
awk: Cannot find or open file fichero.
The source line number is 1.
awk: Cannot find or open file fichero.
The source line number is 1.
syntax error The source line is 1.
The error context is
{print >>> ${ <<<
awk: The statement cannot be correctly parsed.
The source line is 1.
syntax error The source line is 1.
¿POR QUE? sniff sniff
La otra version del script era:
#!/bin/ksh
#
awk '/TextoInicio/,/TextoFin/' fichero > rdo.txt
awk '{print system("`awk '/Texto/ {print$6}' fichero`") " " $0 }' >>
rdo.txt
y me da...
awk: Cannot find or open file fichero.
The source line number is 1.
syntax error The source line is 1.
The error context is
{print system("`awk >>> /Texto/ <<<
awk: The statement cannot be correctly parsed.
The source line is 1.
¿POR QUE? buaaaaaaa sniff sniff, ¿COMO LO PUEDO HACER?
llevo dos dias con esta pelea
gracias, por aguantar la chapa :p
David Rodriguez Torrontegui
dajon en euskalnet.net
_______________________________________________
eside-ghost mailing list
eside-ghost en deusto.es
https://ssl.deusto.es/cgi-bin/mailman/listinfo/eside-ghost
Más información sobre la lista de distribución eside-ghost