If I'm comprehending your question correctly, it appears that "awk" would be a great solution for you. Its learning curve is a bit steep and it appears to be more of a programming language than folks today like, but it was developed back in the early days of Unix itself for exactly the purpose you propose.
AWK is a pattern-matching script language that parses each line received from STDIN (or from a file) according to matching rules that you provide, and upon finding a match, performs actions that you specify. These actions can provide output to STDOUT (or, again, to a file), or can simply move on to the next line of input. All details of the parsing itself are hidden behind the scenes. The strange name comes from the initials of the three pioneers at Bell Labs who created it: Aho, Weinberger, and Kernighan. They later wrote an entire book explaining its use; you might find it on the web, still.
This is only a rough overview of AWK's capabilities; Google for "awk" to find many more leads than you're likely to need. The "man" pages for it, like most man pages, tend to be somewhat cryptic and assume advanced knowledge, but there are several good tutorials and how-tos out there that can get you started, in addition to the original book.
I've used it for more than a decade now. Once you create your script and get it working, you simply call it from the command line and your jobs are done. Biggest time saver I've found -- and I'm one of the laziest computer users you'll ever encounter.
If you run into trouble with it, I'll be happy to try to help. But I think you'll find it fairly easy to learn. Hope this helps!
Last edited by JimKyle; 12-23-2014 at 10:31 AM.
|