by Janis <janis_papanagnou@[EMAIL PROTECTED]
>
Feb 7, 2008 at 04:51 AM
On 7 Feb., 11:28, di98mase <di98m...@[EMAIL PROTECTED]
> wrote:
> Hi all,
>
> I have a problem. I would like to search trough a file for a pattern.
> How do I make sure that the script does not hang? This is my current
> solution:
>
> /value/
> {
Didn't you mean
/value/ {
(i.e. bracket on the same line as the action)
> =A0 =A0foundLog=3D0
This variable is never set to any other value.
> =A0 =A0# from this line and forward search for x.
> =A0 while (foundLog=3D=3D0)
> =A0 {
> =A0 =A0 =A0 getline
Don't use getline; awk does that for you implicitly.
> =A0 =A0 =A0 if ($4=3D=3Dexpected value)
Put constant strings in double quotes.
> =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0return 1
> =A0 =A0 =A0 =A0}
> =A0 =A0 }
>
> }
Instead of all that anove you maybe mean...
/value/ { flag =3D 1 }
flag && $4 =3D=3D "another value" { exit 1 }
Janis
>
> The problem is that the script hangs when it cant find "value". How
> could I avoid this? I would like to add some check for EOF.
>
> /di98mase