Awk extract data block between text strings -


i'm fighting awk again pulling out data log file. area in question of log file looks this, there few thousand lines above , below block:

4c*dj - (b-c)*djk + 2*(2a+b+c)*d1 - 4*(4a+b-3c)*d2 = 0 value =     0.5293955920d-22  alpha matrix in cm-1 axis mode    inertia        coriol.        anharm.        total x    1   -0.37699d-03   -0.36413d-02    0.10830d-01    0.68121d-02 x    2   -0.83656d-03   -0.53163d-02    0.14483d-01    0.83306d-02 x    3   -0.15253d-02   -0.10512d-01    0.20064d-01    0.80264d-02 x    4   -0.17103d-03   -0.73492d-03    0.14953d-01    0.14047d-01 x    5   -0.96312d-03   -0.11748d-01    0.15825d-02   -0.11128d-01 x    6   -0.46095d-03   -0.94225d-02    0.44165d-02   -0.54669d-02 x    7   -0.26926d-01   -0.10167d-01    0.29406d-01   -0.76866d-02 x    8   -0.17827d-02   -0.21079d-01    0.74564d-02   -0.15405d-01 x    9   -0.55840d-02    0.84897d-01   -0.29596d-02    0.76354d-01 x   10   -0.50287d-24    0.36312d-01   -0.44078d-02    0.31904d-01 x   11   -0.48777d-24   -0.63320d-01    0.18876d-02   -0.61432d-01 x   12   -0.35364d-24    0.42877d-01    0.62352d-03    0.43500d-01 y    1   -0.23141d-05   -0.13777d-03    0.53278d-03    0.39270d-03 y    2   -0.62128d-05   -0.87905d-04    0.36602d-03    0.27190d-03 y    3   -0.55613d-05   -0.33722d-04    0.28874d-03    0.24946d-03 y    4   -0.47995d-04   -0.60863d-03    0.17426d-02    0.10860d-02 y    5   -0.36076d-04   -0.20493d-03    0.12026d-03   -0.12075d-03 y    6   -0.12725d-03   -0.61930d-03   -0.15830d-03   -0.90485d-03 y    7   -0.19917d-03   -0.55423d-04    0.10520d-02    0.79740d-03 y    8   -0.48978d-03   -0.13733d-02    0.54899d-03   -0.13141d-02 y    9   -0.11432d-02    0.62058d-03   -0.20074d-04   -0.54272d-03 y   10   -0.16078d-24    0.20852d-02   -0.88466d-04    0.19967d-02 y   11   -0.63877d-25    0.18274d-03   -0.13682d-03    0.45922d-04 y   12   -0.43257d-25    0.92039d-03   -0.61669d-03    0.30370d-03 z    1   -0.69174d-07   -0.23737d-03    0.59290d-03    0.35547d-03 z    2   -0.60773d-05   -0.18704d-03    0.53271d-03    0.33960d-03 z    3   -0.46425d-05   -0.29722d-03    0.57403d-03    0.27217d-03 z    4   -0.22234d-04   -0.47670d-03    0.15748d-02    0.10759d-02 z    5   -0.20254d-04    0.24124d-03    0.11848d-03    0.33947d-03 z    6   -0.42788d-04    0.99264d-04   -0.40246d-04    0.16230d-04 z    7   -0.10941d-03    0.30020d-03    0.13135d-02    0.15043d-02 z    8   -0.19997d-03    0.32196d-03    0.54501d-03    0.66699d-03 z    9   -0.20819d-03    0.45666d-03   -0.67765d-04    0.18071d-03 z   10   -0.55249d-25    0.00000d+00   -0.14491d-03   -0.14491d-03 z   11   -0.55828d-26    0.00000d+00   -0.69139d-04   -0.69139d-04 z   12   -0.26265d-26    0.00000d+00   -0.45200d-03   -0.45200d-03  vibro-rot alpha matrix (cm-1)             a(z)           b(x)           c(y) q( 1)        0.00681        0.00039        0.00036 

i need extract data (in case) " x 1 -0.37..." through "z 12 -0.262..."

i can head , tail file if can awk extract data known point. have 300 of these files, each has different number of lines can't count lines, start "axis mode inertia..." , end "vibro-rot alpha matrix".

i'm trying use:

awk '$1=="axis"&&$2=="mode"{t=1};t;/[0-9]+ "vibro-rot alpha matrix"/{exit}' file.log 

which works start of file (though includes header can subsequently cut off). end part of awk command doesn't work. i've tried end ^vib/{exit} , other things, nothing seems work, few thousand lines of log file when it.

as i'm sure matters, there single space before "axis" @ top, , before "vibro-rot" @ bottom of file. though " $1=="axis"&&$2=="mode" " part doesn't seem care single white space.

what missing cut until line has "vibro-rot alpha matrix" in it?

thanks in advance!

ben

it worked me:

awk '$1 == "axis" && $2 == "mode" {t = 1;} $1 == "vibro-rot" && $2 == "alpha" && $3 == "matrix" {t = 0;} t == 1 && nf == 6 {print $0}' file.log 

in case not want header, try:

awk '$1 == "vibro-rot" && $2 == "alpha" && $3 == "matrix" {t = 0;} t == 1 && nf == 6 {print $0} $1 == "axis" && $2 == "mode" {t = 1;}' file.log 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -