[Tutor] Grep equiv.
Wes Bateman
wbateman@epicrealm.com
Thu, 31 Aug 2000 11:58:35 -0500 (CDT)
Haha! I got it now, makes perfect sense. Knowing so little makes it hard
to pick out errors like that. I knew exactly what you meant when I read
the first "incomplete" message, and I went and got it to work. I chose
the latter of your examples, before I even received it. :) Very cool :)
I figured I that I was misunderstanding what the variable "line" was
referring to. Based on that assumption, I wasn't looking hard at the
quotes around -1 :) Thanks :)
Wes
> Wes,
>
> You are so close. You are using the for loop to check each line in the
> file and that is working great. It's the "if result" line where the problem
> is.
>
> string.find returns a *number* and you are checking it against a
> string, '-1'. There are two possible solutions :
>
> > result = str(string.find(line,'sdb'))
> > if result != '-1' :
>
> -or-
>
> > result = string.find(line,'sdb')
> > if result != -1 :
>
> Either of these will make your script pick the correct lines to print.
>
> sbb
>
> PS sorry for the previous incomplete posting :)
>