Quote:
Originally Posted by kartu
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.