Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Help on sea...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 2152 of 2241
Post > Topic >>

Re: Help on search algorithm

by di98mase <di98mase@[EMAIL PROTECTED] > Feb 7, 2008 at 05:45 AM

On 7 Feb, 13:51, Janis <janis_papanag...@[EMAIL PROTECTED]
> wrote:
> 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
>
> =A0 /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...
>
> =A0 /value/ { flag =3D 1 }
> =A0 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- D=F6lj citerad text -
>
> - Visa citerad text -

Hi Janis,

sorry to take your time with this pointless message. I will start a
new thread with a proper question instead. Thanks anyway.

/di98mase




 3 Posts in Topic:
Help on search algorithm
di98mase <di98mase@[EM  2008-02-07 02:28:52 
Re: Help on search algorithm
Janis <janis_papanagno  2008-02-07 04:51:23 
Re: Help on search algorithm
di98mase <di98mase@[EM  2008-02-07 05:45:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 3:25:37 CDT 2008.