Skip to content

Instantly share code, notes, and snippets.

@RockyRoad29
Created November 20, 2018 14:06
Show Gist options
  • Save RockyRoad29/04ac18146401f030578577d6fcf31af9 to your computer and use it in GitHub Desktop.
Save RockyRoad29/04ac18146401f030578577d6fcf31af9 to your computer and use it in GitHub Desktop.
BEGIN {
FS = "\n" # 4.5.5 Making the Full Line Be a Single Field
# line_re = "^(In|Out)[[]([0-9]+)[]]: (.*)"
# line_re = /(In |Out).([0-9]+).: (.*)/
line_re = "^(In |Out)[[]([0-9]*)[]]: (.*)$"
}
# /^In/ {
# st = substr($0,index($0,':') + 1);
# out = getline();
# if (out) {
# rslt = substr($out, index($out,':') + 1);
# print st, " # =>", rslt
# }
# }
function trace(pfx, var) {
if (0) {
print pfx, var
}
}
NR < 5 {next}
/^#?\s*$/ {print}
#/^#/ {next}
match($0, line_re, fields) {
trace(" -", fields[1])
trace(" -", fields[2])
trace(" -", fields[3])
if (fields[1]=="In " ) {
trace("IN:", $0)
st = fields[3]
if (getline && match($0, line_re, fields) && (fields[1]=="Out")) {
rslt = fields[3]
print st, "# =>", rslt
} else {
print st
}
next;
} else {
}
}
{
trace("UNMATCHED:", $0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment