What unix command(s) can I use to determine the line span that a word appears in text? The "span" being equal to the line number of the last instance of a word minus the line number of the first instance of the word.
1| unix is on two lines
2| once above, and once below
3| unix
In the example above the "span" of 'unix' would be 2 (3-1).
So far I've been trying to make use of grep -n but I don't think that grep is powerful enough. Maybe some use of sed or awk?
Thanks!
span
will be 2 because there are two lines in which the unix word appear or because the unix word apears two times in the same line?