Thursday, July 19, 2012

Capture Contents from Match until the end of the file - in perl

I want the classpath that is set in the manifest.mf
Class-Path:  mscorlib.jar Microsoft.VisualBasic.jar rdVbScriptTranslat
 or.jar js.jar rdsuperscript.jar System.Xml.jar rt.jar System.jar Syst
 em.Data.jar System.Web.jar rt.jar J2SE.Helpers.jar rt.jar fop.jar
The whole file is
$ cat META-INF/MANIFEST.MF 
Manifest-Version: 1.0
VMW-Assembly: c%3A%5CReportDev%5CVB%5CrdXslFoTemplate%5Cbin%5CDebug_Ja
 va%5CrdXslFoTemplate.dll
Created-By: MainSoft Inc
Version-Date: Mon 02/20/06 15:49:54.479
Assembly-Version: 1.0.0.0
Build-Version: 2.2.0.130
Class-Path:  mscorlib.jar Microsoft.VisualBasic.jar rdVbScriptTranslat
 or.jar js.jar rdsuperscript.jar System.Xml.jar rt.jar System.jar Syst
 em.Data.jar System.Web.jar rt.jar J2SE.Helpers.jar rt.jar fop.jar

$ 
What to do.... make the 3 dot match and make the last match \cD which is code for end of file....
$ find . -name 'rdXsl*.jar' -type f | while read dir; do [ -f META-INF/MANIFEST.MF ] && rm -f META-INF/MANIFEST.MF;unzip -q $dir META-INF/MANIFEST.MF; cat META-INF/MANIFEST.MF | perl -ne 'print if /^Class-Path/ ... /\cD/' ; done;

No comments:

Post a Comment