#! /bin/bash - #! /usr/bin/awk -f # Converts the lab organic lab listings from the Course Schedule # into a format that can be pasted into a (6 x n) MSWD table in the # organic lab manual. # # Usage: # - copy rows containing the 233/234 labs from the schedule. # Ok if they contain leading/trailing lines from other # courses. # # - filter through LabSections and paste into the lab-schedule # # pbpaste | LabSections [ | pbcopy ] # # # H.A.Trujillo, 10 Aug 12 # v2: 4 Aug 14 output sorted automatically # # input fields: #CHM.233 L5 30263 Organic.Lab 1.0 R 0600-0850PM CSC 420 Esempio Closed 16 0 # 1 2 3 4 5 6 7 8 9 10 11 12 13 function parse_input() { awk ' BEGIN{ FS="\t" ; OFS="\t" } /CHM 23[34]/{ shr = substr($7,2,1) smin = ":"substr($7,3,2) ehr = substr($7,6,2) emin = ":"substr($7,8,2) " " tolower(substr($7,10,2)) sub(/:00/, "", smin) sub(/0./, substr(ehr,2,1), ehr) time = shr smin " – " ehr emin sub(/M/, "_1-M", $6) sub(/T/, "_2-T", $6) sub(/W/, "_3-W", $6) sub(/R/, "_4-R", $6) sub(/F/, "_5-F", $6) if ( time ~ "pm") { sub( /-/, "_", $6 ) } instr = substr($10, 1, length($10)-2 ) print $2, $3, $6, time, $8 " " $9, instr }' } parse_input | LC_ALL=C sort -k3 -k4 | sed 's/_[1-5][-_]//' exit # vim: ft=awk