in reply to Search file for certain lines

..so if I read this right, you are not interested in lines that begin with h(lower case). You are only interested in outputting lines that start with j, E, or G. If that is in fact the case, then the problem should be pretty simple. Read the file into an array, loop through the array line by line using a regex to check for lines beginning with j, E or G and print them out.

I get the impression I am missing something here... What importance do the lines beginning with h(lower case) have to you?

  • ...the majority is always wrong, and always the last to know about it...
  • The Spice must flow...
  • ..by my will, and by will alone.. I set my mind in motion

Replies are listed 'Best First'.
Re^2: Search file for certain lines
by Anonymous Monk on Sep 23, 2013 at 09:54 UTC

    Read the file into an array,

    Why?

      ..it generally works for me. I like iterating through an array. The question I face rarely is "why not", which boils down to file size in those rare cases. It is easy to see what I am working with using the debugger when I have an array available with everything in it. I am used to working with arrays.... Mostly this is just personal preference, but it works for me, so I suggest it...
      • ...the majority is always wrong, and always the last to know about it...
      • The Spice must flow...
      • ..by my will, and by will alone.. I set my mind in motion