title: awk associative array with pattern as index
body: <p>what would be the best solution to have awk store searched pattern along with lines where it was found in an array.. do i need a shell script for that or it can be done using only awk..</p>
  
  <p>so for example if i search for word 'guitar', it makes an array which holds info that that word was found on line 13, 18 and 89 for example?</p>
  
  <pre><code>awk '/home/ {
  array[$0] = NR 
  }
  END {
  for(i in array) print i, array[i] }' 1-1000.txt
  </code></pre>
  
  <p>for example this would print lines that matched along with number where they were found.. but i need not $0 but that 'home' pattern, as index of associative array which would hold lines as values.. but then again there is problem how to have  multiple values for that one index?? </p>