View Single Post
Old 05-12-2010, 06:39 AM   #1090
Duglum
Enthusiast
Duglum has a complete set of Star Wars action figures.Duglum has a complete set of Star Wars action figures.Duglum has a complete set of Star Wars action figures.
 
Posts: 41
Karma: 282
Join Date: Jun 2009
Device: Sony PRS-505
Quote:
Originally Posted by kartu View Post
I'll try to fix it. So the first search result always contains line number, right?
Exactly. The grep command used outputs the string in the following way:

linenumber:term[space][space]definition[line break]

The command is then piped through "head -n 1" which outputs only the first row in case of multiple results.
As far as I understand the code the first thing that is done is search the position in the string-array at which the colon is. Then it saves everything before that position into the variable lineNo.
After that the variable term is set to the slice of the string from colon + 1 to termIdx, which should indicate the position of the two spaces in the string.
termIdx was never set, however.
Duglum is offline   Reply With Quote