entry_edit_parser.awk (829B)
1 #!/bin/awk 2 { 3 # Remove note 4 sub( />[0-9a-f]{40} */, "" ) 5 6 # Recurrence 7 recur = "" 8 if ( match($0, /\{.*\}/ )){ 9 # Capture it 10 recur = " #" substr($0, RSTART + 1, RLENGTH - 2) 11 sub(/ ->/,"", recur) 12 # Remove it 13 sub( /[[:space:]]\{[[:alnum:]\/\->[:space:]]+\}[[:space:]]/, "" ) 14 } 15 16 # Apt 17 if ( match( $0, ymd_x" @" )){ 18 match($0, /^[0-9\/ -\>@]+|/) 19 d = substr($0, RSTART, RLENGTH) 20 gsub(/ @/,"",d) 21 split(d, da, " -> ") 22 d = (da[1] == da[2]) ? da[1] : da[1] " - " da[2] 23 s = substr($0, RLENGTH + 2) 24 25 # Evt 26 } else if ( match( $0, ymd_x" \\[" )){ 27 d = substr($0, 1, 10) 28 match($0, / *\[[0-9]+\] */) 29 s = substr($0, RSTART + RLENGTH) 30 31 # Todo 32 } else if ( match( $0, /^\[/ )){ 33 match($0, /^\[[[:digit:]]+\]/) 34 d = substr($0, RSTART + 1, RLENGTH - 2) 35 s = substr($0, RLENGTH + 1) 36 } 37 38 print d recur, "::", s 39 }