Hi folks,
I have a text file that I need to parse, and I cant figure it out. The source is a report breaking down softwares from various companies with some basic info about them (see source snippet below). Ultimately what I want is an excel sheet with only Adobe and Microsoft software name and then its version number tab or comma delimited. Id like to use awk as Im trying to get more familiar with it, with a search string that says something like /^ *Location:.*Adobe/ to help determine which entries are applicable, and then print 4 and 6 lines before that. I cant figure out how to do that, and then on top of it, the main catch is that some entries will satisfy the string match, but wont have the Version on the appropriate line (could be 3 instead of 4 lines before matched line), so there has to be a check like "if NR-3 or NR-4 starts with /^ ?Version/ print that and then whatever is 2 lines before that." Ive tried a ton of code snippets and approaches, but nothing even came close to working, so I havent included any.
Here is a bit of the source. Notice the 3rd entry would be an example of something that satisfies the string match but has Version and Software name 3 and 5 lines before instead of 4 and 6. I wouldnt want the 4th entry included at all. Thanks so much for any help!
Bridge CS3:
Version: 2.1.1.9
Last Modified: 11/6/08 10:27 AM
Kind: Universal
Get Info String: 2.1.1.9 (124992), Copyright 2003-2007, Adobe Systems, Inc.
Location: /Applications/Adobe Bridge CS3/Bridge CS3.app
Adobe Bridge CS4:
Version: 3.0.0.464
Last Modified: 9/15/09 5:34 PM
Kind: Universal
Get Info String: 3.0.0.464 (144651), Copyright 2003-2007, Adobe Systems, Inc.
Location: /Applications/Adobe Bridge CS4/Adobe Bridge CS4.app
Device Central:
Version: 1.1.0
Last Modified: 11/6/08 10:53 AM
Kind: Universal
Location: /Applications/Adobe Device Central CS3/Device Central.app
Chess:
Version: 2.4.1
Last Modified: 9/16/09 10:30 AM
Kind: Universal
Get Info String: 2.4.1, Copyright 2003-2008 Apple Inc.
Location: /Applications/Chess.app
The final output should look like this, so I can import it into excel:
Bridge CS3,2.1.1.9,Adobe Bridge CS4,3.0.0.464,Device Central,1.1.0