Hi Kenny,
Well, I'm a AWK newbie, this is my actual code(some friend try to help
me):
~ric)cat script2.awk
#!/usr/bin/awk -f
BEGIN { nStackPtr =3D -1;}
function push(x) { stack[++nStackPtr] =3D x; }
function pop() {
if (nStackPtr =3D=3D -1) return nStackPtr;
return stack[nStackPtr--];
}
{
for (nField =3D 1;nField <=3D NF;nField++)
if (match($nField, "<")) {
nPrevious =3D 0;
for (nLoop =3D nField-0;nLoop > 0 && nPrevious < 3;nLoop--)
if (!match($nLoop, "<")) {
push($nLoop);
nPrevious++;
}
for (nLoop =3D 0;nLoop < nPrevious;nLoop++)
printf("%s ", pop());
printf("%s", $nField);
nFollowing =3D 0;
for (nLoop =3D nField+0;nLoop < NF && nFollowing < 3;nLoop++)
if (!match($nLoop, "<")) {
printf(" %s", $nLoop);
nFollowing++;
}
printf("\n");
}
} # main
~ric)
~ric)awk -f script.awk file
for some sea <bass>.
The <bass> part of the
proposed an elaborate <program> of public works.This
the <program> required several hundred
~ric)
PD: (I need still need remove the "<" ">" chars ,and the "." char, not
continue before/after the point"." )
On 7 abr, 11:17, gaze...@[EMAIL PROTECTED]
(Kenny McCormack)
wrote:
> In article
<81adc279-5a19-46b5-ab30-90d1878a2...@[EMAIL PROTECTED]
>,
>
>
>
>
>
> ric =A0<ricar...@[EMAIL PROTECTED]
> wrote:
> >Hi People:
>
> >Could anybody tell me how can I do this with awk or bash shell?
> >I've a file with this systaxis:
>
> >#cat file
> >I went fishing for some sea <bass>.
> >The <bass> part of the song is very moving.
>
> >he proposed an elaborate <program> of public works.This information
> >was taken from the magazine.
> >the <program> required several hundred lines of code.
>
> >I need a script that gets 3 previus words and 3 words after the
> >tag(<>) from a text file,EXCEPT the words greater than
> >2 chars length(example of,a,an).
>
> >Returning something like this:
>
> >#----------------------------------
> >for some sea bass
> >The bass part the song
> >proprosed elaborate program public works
> >the program required several hundred
>
> OBQuestion: What have you tried so far?
>
> Your problem description sounds like pretty basic AWK. =A0It is hard to
> imagine it taking more than 10-15 minutes to code this up.- Ocultar
texto =
de la cita -
>
> - Mostrar texto de la cita -


|