fork download
  1. BEGIN { OFS = " & " }
  2. NR == 1 || $0 ~ "^$" { next }
  3. NR == 2 { for (i=1;i<NF;i++) { printf("%-2s%s",$i,OFS) }
  4. printf("%s %s\n",$NF," \\\\")
  5. next
  6. }
  7. { for (i=1;i<NF;i++) { printf("%2i%s",$i,OFS) }
  8. printf("%2i%s\n",$NF," \\\\")
  9. }
Success #stdin #stdout 0.01s 4276KB
stdin
January 2007
S M  Tu W  Th  F S
1  2  3  4  5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
stdout
S  & M  & Tu & W  & Th & F  & S  \\
 1 &  2 &  3 &  4 &  5 &  6 \\
 7 &  8 &  9 & 10 & 11 & 12 & 13 \\
14 & 15 & 16 & 17 & 18 & 19 & 20 \\
21 & 22 & 23 & 24 & 25 & 26 & 27 \\
28 & 29 & 30 & 31 \\