awk print lines until next match on the same line - awk

I have the following type of data file:
0.033333 0.000000 0.000000
-46.956 -46.956 -23.678 -23.677 -23.055 -23.054 -22.974 -22.974 -8.033 -8.032
-7.375 -7.356 -7.182 -7.159 -6.695 -6.661 -6.628 -6.598 -4.477 -4.477
-4.470 -4.462 -4.387 -4.380 3.799 3.800 5.939 5.960 6.116 6.117
6.625 6.642 7.648 7.651 7.686 7.687 8.077 8.078 8.123 8.126
8.478 8.497 8.550 8.552 11.625 11.626 12.652 12.653 12.722 12.726
13.860 13.864 14.291 14.293 14.966 15.046 17.063 17.252 18.011 18.015
0.016667 0.000000 0.000000
-46.956 -46.956 -23.677 -23.677 -23.055 -23.054 -22.974 -22.974 -8.037 -8.036
-7.371 -7.361 -7.177 -7.165 -6.686 -6.669 -6.620 -6.605 -4.476 -4.475
-4.471 -4.465 -4.385 -4.382 3.811 3.812 5.942 5.952 6.115 6.115
6.629 6.638 7.651 7.653 7.688 7.689 8.072 8.073 8.122 8.123
8.491 8.501 8.556 8.556 11.612 11.612 12.665 12.665 12.730 12.733
13.835 13.837 14.288 14.289 14.991 15.031 17.132 17.225 18.053 18.055
0.000000 0.000000 0.000000
-46.956 -46.956 -23.677 -23.677 -23.055 -23.055 -22.974 -22.974 -8.038 -8.038
-7.366 -7.366 -7.172 -7.172 -6.678 -6.678 -6.613 -6.613 -4.475 -4.475
-4.469 -4.469 -4.384 -4.384 3.816 3.816 5.946 5.946 6.115 6.115
6.633 6.633 7.653 7.653 7.689 7.689 8.070 8.070 8.122 8.122
8.498 8.498 8.558 8.558 11.607 11.607 12.668 12.668 12.735 12.735
13.827 13.827 14.287 14.287 15.013 15.013 17.186 17.186 18.068 18.068
I need to change this to look like this:
0.033333 0.000000 0.000000 -46.956 -46.956 -23.678 -23.677 -23.055 -23.054 -22.974 -22.974 -8.033 -8.032 -7.375 -7.356 -7.182 -7.159 -6.695 -6.661 -6.628 -6.598 -4.477 -4.477 -4.470 -4.462 -4.387 -4.380 3.799 3.800 5.939 5.960 6.116 6.117 6.625 6.642 7.648 7.651 7.686 7.687 8.077 8.078 8.123 8.126 8.478 8.497 8.550 8.552 11.625 11.626 12.652 12.653 12.722 12.726 13.860 13.864 14.291 14.293 14.966 15.046 17.063 17.252 18.011 18.015
0.016667 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.054 -22.974 -22.974 -8.037 -8.036 -7.371 -7.361 -7.177 -7.165 -6.686 -6.669 -6.620 -6.605 -4.476 -4.475 -4.471 -4.465 -4.385 -4.382 3.811 3.812 5.942 5.952 6.115 6.115 6.629 6.638 7.651 7.653 7.688 7.689 8.072 8.073 8.122 8.123 8.491 8.501 8.556 8.556 11.612 11.612 12.665 12.665 12.730 12.733 13.835 13.837 14.288 14.289 14.991 15.031 17.132 17.225 18.053 18.055
0.000000 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.055 -22.974 -22.974 -8.038 -8.038 -7.366 -7.366 -7.172 -7.172 -6.678 -6.678 -6.613 -6.613 -4.475 -4.475 -4.469 -4.469 -4.384 -4.384 3.816 3.816 5.946 5.946 6.115 6.115 6.633 6.633 7.653 7.653 7.689 7.689 8.070 8.070 8.122 8.122 8.498 8.498 8.558 8.558 11.607 11.607 12.668 12.668 12.735 12.735 13.827 13.827 14.287 14.287 15.013 15.013 17.186 17.186 18.068 18.068
Basically look for the lines with 3 fields only and from there start to remove the line break character until the next line with 3 fields. Also I want to remove all the spaces at the beginning of the line with the 3 fields. Hope this is clearer from the above example.
I have tried the following code:
BEGIN {
ORS=" ";
}
NF==3 {x=NR+6} (NR<=x) {print}
Trouble is that I get a completely different result. I don't know how to add a \n character before the next pattern match. So I get:
0.033333 0.000000 0.000000 -46.956 -46.956 -23.678 -23.677 -23.055 -23.054 -22.974 -22.974 -8.033 -8.032 -7.375 -7.356 -7.182 -7.159 -6.695 -6.661 -6.628 -6.598 -4.477 -4.477 -4.470 -4.462 -4.387 -4.380 3.799 3.800 5.939 5.960 6.116 6.117 6.625 6.642 7.648 7.651 7.686 7.687 8.077 8.078 8.123 8.126 8.478 8.497 8.550 8.552 11.625 11.626 12.652 12.653 12.722 12.726 13.860 13.864 14.291 14.293 14.966 15.046 17.063 17.252 18.011 18.015 0.016667 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.054 -22.974 -22.974 -8.037 -8.036 -7.371 -7.361 -7.177 -7.165 -6.686 -6.669 -6.620 -6.605 -4.476 -4.475 -4.471 -4.465 -4.385 -4.382 3.811 3.812 5.942 5.952 6.115 6.115 6.629 6.638 7.651 7.653 7.688 7.689 8.072 8.073 8.122 8.123 8.491 8.501 8.556 8.556 11.612 11.612 12.665 12.665 12.730 12.733 13.835 13.837 14.288 14.289 14.991 15.031 17.132 17.225 18.053 18.055 0.000000 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.055 -22.974 -22.974 -8.038 -8.038 -7.366 -7.366 -7.172 -7.172 -6.678 -6.678 -6.613 -6.613 -4.475 -4.475 -4.469 -4.469 -4.384 -4.384 3.816 3.816 5.946 5.946 6.115 6.115 6.633 6.633 7.653 7.653 7.689 7.689 8.070 8.070 8.122 8.122 8.498 8.498 8.558 8.558 11.607 11.607 12.668 12.668 12.735 12.735 13.827 13.827 14.287 14.287 15.013 15.013 17.186 17.186 18.068
I also don't know how to get rid of all the space characters on the line with the pattern match.

One awk idea:
awk '
NF==3 { sub(/^[[:space:]]+/,"") # remove leading white space
printf "%s%s",eol,$0 # initially eol="" (undefined)
eol="\n" # next time print this line with a leading "\n" (to close out previous line)
next}
{ printf "%s%s",OFS,$0 } # OP will need to decide if the extra OFS is needed here or can be removed
END { print "" } # terminate last line of output with a "\n"
' file
This generates:
0.033333 0.000000 0.000000 -46.956 -46.956 -23.678 -23.677 -23.055 -23.054 -22.974 -22.974 -8.033 -8.032 -7.375 -7.356 -7.182 -7.159 -6.695 -6.661 -6.628 -6.598 -4.477 -4.477 -4.470 -4.462 -4.387 -4.380 3.799 3.800 5.939 5.960 6.116 6.117 6.625 6.642 7.648 7.651 7.686 7.687 8.077 8.078 8.123 8.126 8.478 8.497 8.550 8.552 11.625 11.626 12.652 12.653 12.722 12.726 13.860 13.864 14.291 14.293 14.966 15.046 17.063 17.252 18.011 18.015
0.016667 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.054 -22.974 -22.974 -8.037 -8.036 -7.371 -7.361 -7.177 -7.165 -6.686 -6.669 -6.620 -6.605 -4.476 -4.475 -4.471 -4.465 -4.385 -4.382 3.811 3.812 5.942 5.952 6.115 6.115 6.629 6.638 7.651 7.653 7.688 7.689 8.072 8.073 8.122 8.123 8.491 8.501 8.556 8.556 11.612 11.612 12.665 12.665 12.730 12.733 13.835 13.837 14.288 14.289 14.991 15.031 17.132 17.225 18.053 18.055
0.000000 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.055 -22.974 -22.974 -8.038 -8.038 -7.366 -7.366 -7.172 -7.172 -6.678 -6.678 -6.613 -6.613 -4.475 -4.475 -4.469 -4.469 -4.384 -4.384 3.816 3.816 5.946 5.946 6.115 6.115 6.633 6.633 7.653 7.653 7.689 7.689 8.070 8.070 8.122 8.122 8.498 8.498 8.558 8.558 11.607 11.607 12.668 12.668 12.735 12.735 13.827 13.827 14.287 14.287 15.013 15.013 17.186 17.186 18.068 18.068

Since you always have 7 lines per record, all you need is this, using GNU awk for multi-char RS and RT:
$ awk -v RS='([^\n]+\n){7}' -v ORS= '{$0=RT; $1=$1} 1' file
0.033333 0.000000 0.000000 -46.956 -46.956 -23.678 -23.677 -23.055 -23.054 -22.974 -22.974 -8.033 -8.032 -7.375 -7.356 -7.182 -7.159 -6.695 -6.661 -6.628 -6.598 -4.477 -4.477 -4.470 -4.462 -4.387 -4.380 3.799 3.800 5.939 5.960 6.116 6.117 6.625 6.642 7.648 7.651 7.686 7.687 8.077 8.078 8.123 8.126 8.478 8.497 8.550 8.552 11.625 11.626 12.652 12.653 12.722 12.726 13.860 13.864 14.291 14.293 14.966 15.046 17.063 17.252 18.011 18.015
0.016667 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.054 -22.974 -22.974 -8.037 -8.036 -7.371 -7.361 -7.177 -7.165 -6.686 -6.669 -6.620 -6.605 -4.476 -4.475 -4.471 -4.465 -4.385 -4.382 3.811 3.812 5.942 5.952 6.115 6.115 6.629 6.638 7.651 7.653 7.688 7.689 8.072 8.073 8.122 8.123 8.491 8.501 8.556 8.556 11.612 11.612 12.665 12.665 12.730 12.733 13.835 13.837 14.288 14.289 14.991 15.031 17.132 17.225 18.053 18.055
0.000000 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.055 -22.974 -22.974 -8.038 -8.038 -7.366 -7.366 -7.172 -7.172 -6.678 -6.678 -6.613 -6.613 -4.475 -4.475 -4.469 -4.469 -4.384 -4.384 3.816 3.816 5.946 5.946 6.115 6.115 6.633 6.633 7.653 7.653 7.689 7.689 8.070 8.070 8.122 8.122 8.498 8.498 8.558 8.558 11.607 11.607 12.668 12.668 12.735 12.735 13.827 13.827 14.287 14.287 15.013 15.013 17.186 17.186 18.068 18.06
or this using any awk:
$ awk '{rec=rec FS $0} !(NR%7){$0=rec; rec=""; $1=$1; print}' file
0.033333 0.000000 0.000000 -46.956 -46.956 -23.678 -23.677 -23.055 -23.054 -22.974 -22.974 -8.033 -8.032 -7.375 -7.356 -7.182 -7.159 -6.695 -6.661 -6.628 -6.598 -4.477 -4.477 -4.470 -4.462 -4.387 -4.380 3.799 3.800 5.939 5.960 6.116 6.117 6.625 6.642 7.648 7.651 7.686 7.687 8.077 8.078 8.123 8.126 8.478 8.497 8.550 8.552 11.625 11.626 12.652 12.653 12.722 12.726 13.860 13.864 14.291 14.293 14.966 15.046 17.063 17.252 18.011 18.015
0.016667 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.054 -22.974 -22.974 -8.037 -8.036 -7.371 -7.361 -7.177 -7.165 -6.686 -6.669 -6.620 -6.605 -4.476 -4.475 -4.471 -4.465 -4.385 -4.382 3.811 3.812 5.942 5.952 6.115 6.115 6.629 6.638 7.651 7.653 7.688 7.689 8.072 8.073 8.122 8.123 8.491 8.501 8.556 8.556 11.612 11.612 12.665 12.665 12.730 12.733 13.835 13.837 14.288 14.289 14.991 15.031 17.132 17.225 18.053 18.055
0.000000 0.000000 0.000000 -46.956 -46.956 -23.677 -23.677 -23.055 -23.055 -22.974 -22.974 -8.038 -8.038 -7.366 -7.366 -7.172 -7.172 -6.678 -6.678 -6.613 -6.613 -4.475 -4.475 -4.469 -4.469 -4.384 -4.384 3.816 3.816 5.946 5.946 6.115 6.115 6.633 6.633 7.653 7.653 7.689 7.689 8.070 8.070 8.122 8.122 8.498 8.498 8.558 8.558 11.607 11.607 12.668 12.668 12.735 12.735 13.827 13.827 14.287 14.287 15.013 15.013 17.186 17.186 18.068 18.06

awk -v ORS= '
NF==3 {
if (NR>1) print "\n"
sub(/^[[:space:]]*/,"")
}
1;
END { print "\n" }
' file
unset default newline for print (OFS=)
when 3-field line detected
print a newline (unless this is first line)
strip leading whitespace
default print (1;) - with no trailing newline
print final newline at the end
This code assumes all lines have leading whitespace (as shown in the sample input), so that no field separator is needed on joined lines.
Your original code is actually not far from working:
awk '
BEGIN { ORS=" " } # or maybe ORS=""
NF==3 {
sub(/^[[:space:]]*/,"") # strip leading whitespace
x = NR+6
}
NR<=x { print }
NR==x { printf "\n" }
' file
An even simpler solution if we know that the 3-field lines always have much more leading whitespace than any other line (e.g. 8 or more):
awk -v RS='[[:space:]]{8,}' 'gsub(/\n/,"")' file
set input record separator to be lots of spaces
strip all embedded newlines
implicit print will append a trailing newline
Note that the first (empty) record is conveniently elided because gsub fails (no newlines removed) and so does not trigger the implicit print.
Another note: This requires a version of awk that supports multi-character RS (e.g. gawk, busybox; but not mawk, original-awk).
Final note: This method, while shorter code, appears to run significantly more slowly (about 10% of the speed of the first version).
For super-slow (about 1% the speed of the first awk version), and if squeezing whitespace is not a problem, there is also the extremely compact:
<file xargs -n63

Related

VerifyError: Bad type on operand stack dropwizard

We upgraded the java version to 11 in a microservice.
When we tried to run the app, we got the following message:
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/template/main/App.initialize(Lio/dropwizard/setup/Bootstrap;)V #153: invokespecial
Reason:
Type 'io/dropwizard/configuration/EnvironmentVariableSubstitutor' (current frame, stack[4]) is not assignable to 'org/apache/commons/text/StrSubstitutor'
Current Frame:
bci: #153
flags: { }
locals: { 'com/template/main/App', 'io/dropwizard/setup/Bootstrap', 'com/bendb/dropwizard/jooq/JooqBundle' }
stack: { 'io/dropwizard/setup/Bootstrap', uninitialized 137, uninitialized 137, 'io/dropwizard/configuration/ConfigurationSourceProvider', 'io/dropwizard/configuration/EnvironmentVariableSubstitutor' }
Bytecode:
0000000: 2a2b b700 052a b600 064d 2b2c b600 072b
0000010: bb00 0859 b700 09b6 0007 2bbb 000a 59b7
0000020: 000b b600 0c2a b800 0d12 0eb6 000f bb00
0000030: 1059 b700 11b6 0012 bb00 1359 2cb7 0014
0000040: b600 12bb 0015 59b7 0016 b600 12bb 0017
0000050: 59b7 0018 b600 12bb 0019 59b7 001a b600
0000060: 12bb 001b 59b7 001c b600 1204 bd00 1d59
0000070: 0312 1e53 b600 1fb2 0020 b600 21b5 0022
0000080: 2b2a b400 22b6 0007 2bbb 0023 592b b600
0000090: 24bb 0025 5903 b700 26b7 0027 b600 282b
00000a0: bb00 2959 2ab7 002a b600 0c2b bb00 2b59
00000b0: 2ab7 002c b600 07b1
Any idea how can we fix it?

Count how many repeated times each record appears and select minimum and maximum of specific column

1 .- Fist i would like to count how many times each record appears the key is substr($0,20,18), Print always the last line for each record repeated and print in the output file in last column
2.- Find the minimum and maximum value on column 7 and print in columns 4 and 5 in output file.
Input file
M G 36829.00 37145.00 1 2161 36840.00 37146.00 37576
M G 36829.00 37145.00 217 4321 36852.00 37146.00 37576
M G 36829.00 37145.00 433 6481 36864.00 37146.00 37576
M G 36829.00 37145.00 649 8641 36876.00 37146.00 37576
M G 36829.00 37145.00 865 10801 36888.00 37146.00 37576
M G 36833.00 38033.00 1 4321 36840.00 37602.00 38464
M G 36833.00 38033.00 433 8641 36852.00 37602.00 38464
M G 36833.00 38033.00 865 12961 36864.00 37602.00 38464
M G 36833.00 38033.00 1297 17281 36876.00 37602.00 38464
M G 36833.00 38033.00 1729 21601 36888.00 37602.00 38464
M G 37265.00 38105.00 1 4321 36840.00 37674.00 38536
M G 37265.00 38105.00 433 8641 36852.00 37674.00 38536
M G 37265.00 38105.00 865 12961 36864.00 37674.00 38536
M G 37265.00 38105.00 1297 17281 36876.00 37674.00 38536
M G 37265.00 38105.00 1729 21601 36888.00 37674.00 38536
M G 37265.00 38105.00 2161 25921 36900.00 37674.00 38536
M G 37271.00 38885.00 1 2211 36840.00 38454.00 38894
M G 37271.00 38885.00 222 4421 36852.00 38454.00 38894
M G 37271.00 38885.00 443 6631 36864.00 38454.00 38894
M G 37271.00 38885.00 664 8841 36876.00 38454.00 38894
Desired Output file
36829.00 37145.00 10801 36840.00 36888.00 37146.00 37576 5
36833.00 38033.00 21601 36840.00 36888.00 37602.00 38464 5
37265.00 38105.00 25921 36840.00 36900.00 37674.00 38536 6
37271.00 38885.00 8841 36840.00 36876.00 38454.00 38894 4
I tried.
To count how many times each record appears.
awk '{dups[substr($0,20,18)]++} END{for (num in dups) {print num,dups[num]}}' file
To find the minimum and maximum in column 7.
awk '{\
l = substr($7,1,5);\
printf ("%5d \n",l);\
}' file |
awk ' {D1=substr($1, 1, 5)
D2=substr($1, 1, 5)+0
}
!(D1 in MIN) {MIN[D1]=D2
MAX[D1]=D2
next
}
D2 < MIN[D1] {MIN[D1]=D2}
D2 > MAX[D1] {MAX[D1]=D2}
END {for (m in MIN) print m, MIN[m], MAX[m]}
Thanks in advance.
It sounds like this is what you're trying to do:
$ cat tst.awk
{ currKey = $3 FS $4 }
currKey != prevKey { prt(); min=$7; cnt=0 }
{ prevRec=$0; prevKey=currKey; max=$7; cnt++ }
END { prt() }
function prt( f) {
if ( cnt ) {
split(prevRec,f)
print f[3], f[4], f[6], min, max, f[7], f[8], cnt
}
}
$ sort -k3,4n -k7n file | awk -f tst.awk | column -t
36829.00 37145.00 10801 36840.00 36888.00 36888.00 37146.00 5
36833.00 38033.00 21601 36840.00 36888.00 36888.00 37602.00 5
37265.00 38105.00 25921 36840.00 36900.00 36900.00 37674.00 6
37271.00 38885.00 8841 36840.00 36876.00 36876.00 38454.00 4
Does not keep the order of input file but works even if your file is not ordered by key first
awk '
{
$7+=0;
COUNT[$9]+=1;
C1[$9]=$3;
C2[$9]=$4;
C3[$9]=$6;
C6[$9]=$8
}
!($9 in MIN){
MIN[$9]=$7;
MAX[$9]=$7;
next
}
$7<MIN[$9]{
MIN[$9]=$7
}
$7>MAX[$9]{
MAX[$9]=$7
}
END{
for(id in COUNT){
print C1[id], C2[id], C3[id], MIN[id], MAX[id], C6[id], id, COUNT[id]
}
}' <file>
Output :
37271.00 38885.00 8841 36840 36876 38454.00 38894 4
36833.00 38033.00 21601 36840 36888 37602.00 38464 5
36829.00 37145.00 10801 36840 36888 37146.00 37576 5
37265.00 38105.00 25921 36840 36900 37674.00 38536 6
Could you please try following.
awk '
{
val=substr($0,20,18)
$1=$2=""
sub(/^[[:space:]]+/,"")
}
prev!=val && prev{
print first,second,min,max,third,count
count=""
}
{
min=min<$5?min?min:$5:$5
max=max>$5?max:$5
prev=val
count++
first=$1 OFS $2
second=$4
third=$(NF-1) OFS $NF
}
END{
if(prev){
print first,second,min,max,third,count
}
}
' Input_file | column -t

tornado-maven-osgi-project template for IntelliJ does not work [duplicate]

I am using the Kotlin getting started guide to setup Kotlin for the first time on IntelliJ IDEA with the following configuration:
IntelliJ IDEA 2017.2.5
Build #IC-172.4343.14, built on September 26, 2017
JRE: 1.8.0_152-release-915-b12 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6
I created an App.kt file in a new Kotlin project with the following code:
fun main(args: Array<String>) {
println("hello")
}
On running the code through the IDE, I get the following error:
Error:Internal error: (java.lang.VerifyError) Uninitialized object exists on backward branch 90
Exception Details:
Location:
org/jetbrains/kotlin/jps/build/KotlinBuilder.createCompileEnvironment(Ljava/util/Map;Lorg/jetbrains/kotlin/incremental/components/LookupTracker;Lorg/jetbrains/jps/incremental/CompileContext;Lorg/jetbrains/kotlin/jps/build/KotlinBuilder$MessageCollectorAdapter;)Lorg/jetbrains/kotlin/compilerRunner/JpsCompilerEnvironment; #171: goto
Reason:
Error exists in the bytecode
Bytecode:
0000000: bb03 fe59 b703 ff3a 0619 063a 0719 0713
0000010: 02d7 2cb6 0403 5719 0713 0405 bb04 0759
0000020: 2b3a 083a 093a 0a3a 0b3a 0c19 083a 0dbb
0000030: 0409 5919 08b9 040a 0100 b804 10b7 0411
0000040: c002 893a 0e19 0db9 028c 0100 c000 b03a
0000050: 0f19 0fb9 00b9 0100 3a10 1910 b900 be01
0000060: 0099 004d 1910 b900 c201 003a 1119 0e19
0000070: 11c0 028e 3a12 3a13 1912 b902 9101 00c0
0000080: 00c4 b804 173a 1419 1319 1419 11c0 028e
0000090: 3a15 3a16 3a17 1915 b902 9401 003a 1819
00000a0: 1719 1619 18b9 041b 0300 57a7 ffaf 190e
00000b0: 0000 3a13 190c 190b 190a 1909 1913 b704
00000c0: 1eb6 0403 5719 0713 0420 bb04 2259 2c2b
00000d0: 2db7 0425 b604 0357 1907 b604 283a 052a
00000e0: b704 2c3a 0619 06c6 0010 1906 b904 3101
00000f0: 00b6 013c 9a00 1319 04b2 0216 1304 3301
0000100: 0701 b801 fa01 b0bb 0262 5919 0619 05b2
0000110: 002e b604 3719 04c0 01c7 bb04 3959 b704
0000120: 3ab7 043d b0
Stackmap Table:
full_frame(#90,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Top,Object[#1022],Object[#1022],Object[#649],Uninitialized[#28],Uninitialized[#28],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187]},{})
same_frame_extended(#174)
full_frame(#247,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Object[#1102],Object[#1070],Object[#1022],Object[#649],Object[#1031],Object[#1031],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187],Top,Top,Object[#649]},{})
same_frame(#263)
java.lang.VerifyError: Uninitialized object exists on backward branch 90
Exception Details:
Location:
org/jetbrains/kotlin/jps/build/KotlinBuilder.createCompileEnvironment(Ljava/util/Map;Lorg/jetbrains/kotlin/incremental/components/LookupTracker;Lorg/jetbrains/jps/incremental/CompileContext;Lorg/jetbrains/kotlin/jps/build/KotlinBuilder$MessageCollectorAdapter;)Lorg/jetbrains/kotlin/compilerRunner/JpsCompilerEnvironment; #171: goto
Reason:
Error exists in the bytecode
Bytecode:
0000000: bb03 fe59 b703 ff3a 0619 063a 0719 0713
0000010: 02d7 2cb6 0403 5719 0713 0405 bb04 0759
0000020: 2b3a 083a 093a 0a3a 0b3a 0c19 083a 0dbb
0000030: 0409 5919 08b9 040a 0100 b804 10b7 0411
0000040: c002 893a 0e19 0db9 028c 0100 c000 b03a
0000050: 0f19 0fb9 00b9 0100 3a10 1910 b900 be01
0000060: 0099 004d 1910 b900 c201 003a 1119 0e19
0000070: 11c0 028e 3a12 3a13 1912 b902 9101 00c0
0000080: 00c4 b804 173a 1419 1319 1419 11c0 028e
0000090: 3a15 3a16 3a17 1915 b902 9401 003a 1819
00000a0: 1719 1619 18b9 041b 0300 57a7 ffaf 190e
00000b0: 0000 3a13 190c 190b 190a 1909 1913 b704
00000c0: 1eb6 0403 5719 0713 0420 bb04 2259 2c2b
00000d0: 2db7 0425 b604 0357 1907 b604 283a 052a
00000e0: b704 2c3a 0619 06c6 0010 1906 b904 3101
00000f0: 00b6 013c 9a00 1319 04b2 0216 1304 3301
0000100: 0701 b801 fa01 b0bb 0262 5919 0619 05b2
0000110: 002e b604 3719 04c0 01c7 bb04 3959 b704
0000120: 3ab7 043d b0
Stackmap Table:
full_frame(#90,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Top,Object[#1022],Object[#1022],Object[#649],Uninitialized[#28],Uninitialized[#28],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187]},{})
same_frame_extended(#174)
full_frame(#247,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Object[#1102],Object[#1070],Object[#1022],Object[#649],Object[#1031],Object[#1031],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187],Top,Top,Object[#649]},{})
same_frame(#263)
at org.jetbrains.kotlin.jps.build.KotlinBuilderService.createModuleLevelBuilders(KotlinBuilderService.java:30)
at org.jetbrains.jps.incremental.BuilderRegistry.<init>(BuilderRegistry.java:54)
at org.jetbrains.jps.incremental.BuilderRegistry.<init>(BuilderRegistry.java:33)
at org.jetbrains.jps.incremental.BuilderRegistry$Holder.<clinit>(BuilderRegistry.java:36)
at org.jetbrains.jps.incremental.BuilderRegistry.getInstance(BuilderRegistry.java:43)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:133)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:295)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:236)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$$Lambda$3/1147174008.run(Unknown Source)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$$Lambda$1/684874119.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
This is due to a bug in earlier JDK 8 versions. Open up the project structure for your project and change your project SDK to a more recent version.
Upgrading from JDK 1.8.0_11 to 1.80_72 solved the problem for me.
Just check "Use embedded JDK" in File>Project Structure>SDK Location> JDK Location

Kotlin VerifyError: Uninitialized object exists on backward branch 90

I am using the Kotlin getting started guide to setup Kotlin for the first time on IntelliJ IDEA with the following configuration:
IntelliJ IDEA 2017.2.5
Build #IC-172.4343.14, built on September 26, 2017
JRE: 1.8.0_152-release-915-b12 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6
I created an App.kt file in a new Kotlin project with the following code:
fun main(args: Array<String>) {
println("hello")
}
On running the code through the IDE, I get the following error:
Error:Internal error: (java.lang.VerifyError) Uninitialized object exists on backward branch 90
Exception Details:
Location:
org/jetbrains/kotlin/jps/build/KotlinBuilder.createCompileEnvironment(Ljava/util/Map;Lorg/jetbrains/kotlin/incremental/components/LookupTracker;Lorg/jetbrains/jps/incremental/CompileContext;Lorg/jetbrains/kotlin/jps/build/KotlinBuilder$MessageCollectorAdapter;)Lorg/jetbrains/kotlin/compilerRunner/JpsCompilerEnvironment; #171: goto
Reason:
Error exists in the bytecode
Bytecode:
0000000: bb03 fe59 b703 ff3a 0619 063a 0719 0713
0000010: 02d7 2cb6 0403 5719 0713 0405 bb04 0759
0000020: 2b3a 083a 093a 0a3a 0b3a 0c19 083a 0dbb
0000030: 0409 5919 08b9 040a 0100 b804 10b7 0411
0000040: c002 893a 0e19 0db9 028c 0100 c000 b03a
0000050: 0f19 0fb9 00b9 0100 3a10 1910 b900 be01
0000060: 0099 004d 1910 b900 c201 003a 1119 0e19
0000070: 11c0 028e 3a12 3a13 1912 b902 9101 00c0
0000080: 00c4 b804 173a 1419 1319 1419 11c0 028e
0000090: 3a15 3a16 3a17 1915 b902 9401 003a 1819
00000a0: 1719 1619 18b9 041b 0300 57a7 ffaf 190e
00000b0: 0000 3a13 190c 190b 190a 1909 1913 b704
00000c0: 1eb6 0403 5719 0713 0420 bb04 2259 2c2b
00000d0: 2db7 0425 b604 0357 1907 b604 283a 052a
00000e0: b704 2c3a 0619 06c6 0010 1906 b904 3101
00000f0: 00b6 013c 9a00 1319 04b2 0216 1304 3301
0000100: 0701 b801 fa01 b0bb 0262 5919 0619 05b2
0000110: 002e b604 3719 04c0 01c7 bb04 3959 b704
0000120: 3ab7 043d b0
Stackmap Table:
full_frame(#90,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Top,Object[#1022],Object[#1022],Object[#649],Uninitialized[#28],Uninitialized[#28],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187]},{})
same_frame_extended(#174)
full_frame(#247,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Object[#1102],Object[#1070],Object[#1022],Object[#649],Object[#1031],Object[#1031],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187],Top,Top,Object[#649]},{})
same_frame(#263)
java.lang.VerifyError: Uninitialized object exists on backward branch 90
Exception Details:
Location:
org/jetbrains/kotlin/jps/build/KotlinBuilder.createCompileEnvironment(Ljava/util/Map;Lorg/jetbrains/kotlin/incremental/components/LookupTracker;Lorg/jetbrains/jps/incremental/CompileContext;Lorg/jetbrains/kotlin/jps/build/KotlinBuilder$MessageCollectorAdapter;)Lorg/jetbrains/kotlin/compilerRunner/JpsCompilerEnvironment; #171: goto
Reason:
Error exists in the bytecode
Bytecode:
0000000: bb03 fe59 b703 ff3a 0619 063a 0719 0713
0000010: 02d7 2cb6 0403 5719 0713 0405 bb04 0759
0000020: 2b3a 083a 093a 0a3a 0b3a 0c19 083a 0dbb
0000030: 0409 5919 08b9 040a 0100 b804 10b7 0411
0000040: c002 893a 0e19 0db9 028c 0100 c000 b03a
0000050: 0f19 0fb9 00b9 0100 3a10 1910 b900 be01
0000060: 0099 004d 1910 b900 c201 003a 1119 0e19
0000070: 11c0 028e 3a12 3a13 1912 b902 9101 00c0
0000080: 00c4 b804 173a 1419 1319 1419 11c0 028e
0000090: 3a15 3a16 3a17 1915 b902 9401 003a 1819
00000a0: 1719 1619 18b9 041b 0300 57a7 ffaf 190e
00000b0: 0000 3a13 190c 190b 190a 1909 1913 b704
00000c0: 1eb6 0403 5719 0713 0420 bb04 2259 2c2b
00000d0: 2db7 0425 b604 0357 1907 b604 283a 052a
00000e0: b704 2c3a 0619 06c6 0010 1906 b904 3101
00000f0: 00b6 013c 9a00 1319 04b2 0216 1304 3301
0000100: 0701 b801 fa01 b0bb 0262 5919 0619 05b2
0000110: 002e b604 3719 04c0 01c7 bb04 3959 b704
0000120: 3ab7 043d b0
Stackmap Table:
full_frame(#90,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Top,Object[#1022],Object[#1022],Object[#649],Uninitialized[#28],Uninitialized[#28],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187]},{})
same_frame_extended(#174)
full_frame(#247,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Object[#1102],Object[#1070],Object[#1022],Object[#649],Object[#1031],Object[#1031],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187],Top,Top,Object[#649]},{})
same_frame(#263)
at org.jetbrains.kotlin.jps.build.KotlinBuilderService.createModuleLevelBuilders(KotlinBuilderService.java:30)
at org.jetbrains.jps.incremental.BuilderRegistry.<init>(BuilderRegistry.java:54)
at org.jetbrains.jps.incremental.BuilderRegistry.<init>(BuilderRegistry.java:33)
at org.jetbrains.jps.incremental.BuilderRegistry$Holder.<clinit>(BuilderRegistry.java:36)
at org.jetbrains.jps.incremental.BuilderRegistry.getInstance(BuilderRegistry.java:43)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:133)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:295)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:236)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$$Lambda$3/1147174008.run(Unknown Source)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$$Lambda$1/684874119.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
This is due to a bug in earlier JDK 8 versions. Open up the project structure for your project and change your project SDK to a more recent version.
Upgrading from JDK 1.8.0_11 to 1.80_72 solved the problem for me.
Just check "Use embedded JDK" in File>Project Structure>SDK Location> JDK Location

Replace a pattern-matching field with field's value from previous row

maybe the title is not a good description but, essentially, this is the problem I am trying to solve:
I have a text file with n rows and m space-separater fields in each row
if field j of row i matches a pattern, replace it with field j from row i - 1
I am not forced to use AWK (GAWK in this instance), but it seemed a good choice for this operation. This is the sript I wrote and it work as expected, but I was wondering if there is a more time-efficient way to solve the problem
{
if ($0!~/NoData/) {
split($0, data, " ");
print $0
} else {
split($0, row, " ", seps);
for(i in row) {if (row[i]~/NoData/) row[i]=data[i]; else data[i]=row[i]; printf "%s%s", row[i], seps[i];}
printf "\n"
}
}
As a sample, the script, running on this input file
0.8147 0.2785 0.9572 0.7922 0.6787 0.7060
0.9058 0.5469 0.4854 0.9595 0.7577 0.0318
0.1270 0.9575 0.8003 0.6557 0.7431 0.2769
0.9134 0.9649 NoData 0.0357 0.3922 0.0462
0.6324 0.1576 NoData NoData 0.6555 0.0971
0.0975 0.9706 NoData NoData 0.1712 0.8235
should produce this result
0.8147 0.2785 0.9572 0.7922 0.6787 0.7060
0.9058 0.5469 0.4854 0.9595 0.7577 0.0318
0.1270 0.9575 0.8003 0.6557 0.7431 0.2769
0.9134 0.9649 0.8003 0.0357 0.3922 0.0462
0.6324 0.1576 0.8003 0.0357 0.6555 0.0971
0.0975 0.9706 0.8003 0.0357 0.1712 0.8235
awk '{for(i=1;i<=NF;i++){ if($i~/NoData/){ $i=last[i]; } last[i]=$i } }1' file
If you want to preserve original formatting, you may use below, if you have gawk 4th argument for split may be utilized.
awk '{
split($0,D,/[^[:space:]]*/);
s = "";
for(i=1;i<=NF;i++){
if($i~/NoData/){ $i = last[i]; }
last[i]=$i ;
s = s sprintf("%s%s",D[i],$i)
}
print s
}' file
OR by setting OFS="" or OFS=
awk -v OFS= '{
split($0,D,/[^[:space:]]*/);
for(i=1;i<=NF;i++){
if($i~/NoData/){ $i = last[i]; }
last[i]=$i ;
$i = sprintf("%s%s",D[i],$i)
}
}1' file
Example - 1 ( Preserve Formatting )
$ cat file
0.8147 0.2785 0.9572 0.7922 0.6787 0.7060
0.9058 0.5469 0.4854 0.9595 0.7577 0.0318
0.1270 0.9575 0.8003 0.6557 0.7431 0.2769
0.9134 0.9649 NoData 0.0357 0.3922 0.0462
0.6324 0.1576 NoData NoData 0.6555 0.0971
0.0975 0.9706 NoData NoData 0.1712 0.8235
$ awk '{
split($0,D,/[^[:space:]]*/);
s = "";
for(i=1;i<=NF;i++){
if($i~/NoData/){ $i = last[i]; }
last[i]=$i ;
s = s sprintf("%s%s",D[i],$i)
}
print s
}' file
0.8147 0.2785 0.9572 0.7922 0.6787 0.7060
0.9058 0.5469 0.4854 0.9595 0.7577 0.0318
0.1270 0.9575 0.8003 0.6557 0.7431 0.2769
0.9134 0.9649 0.8003 0.0357 0.3922 0.0462
0.6324 0.1576 0.8003 0.0357 0.6555 0.0971
0.0975 0.9706 0.8003 0.0357 0.1712 0.8235
Example - 2 ( Without Preserving Source Formatting )
It takes single space as output separator by default, in case if you set OFS it will override default value.
$ cat file
0.8147 0.2785 0.9572 0.7922 0.6787 0.7060
0.9058 0.5469 0.4854 0.9595 0.7577 0.0318
0.1270 0.9575 0.8003 0.6557 0.7431 0.2769
0.9134 0.9649 NoData 0.0357 0.3922 0.0462
0.6324 0.1576 NoData NoData 0.6555 0.0971
0.0975 0.9706 NoData NoData 0.1712 0.8235
$ awk '{for(i=1;i<=NF;i++){ if($i~/NoData/){ $i=last[i]; } last[i]=$i } }1' file
0.8147 0.2785 0.9572 0.7922 0.6787 0.7060
0.9058 0.5469 0.4854 0.9595 0.7577 0.0318
0.1270 0.9575 0.8003 0.6557 0.7431 0.2769
0.9134 0.9649 0.8003 0.0357 0.3922 0.0462
0.6324 0.1576 0.8003 0.0357 0.6555 0.0971
0.0975 0.9706 0.8003 0.0357 0.1712 0.8235