diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-04-23 18:59:15 +0200 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-04-23 18:59:15 +0200 |
commit | af38cb02a9ca95b20056bc92e73fe72a45d1f523 (patch) | |
tree | 41628cac3a02d2c4dcf4ff6ecbb1fb8c5378db20 /tabize | |
download | scripts-af38cb02a9ca95b20056bc92e73fe72a45d1f523.tar.gz |
Initial checkin.
Diffstat (limited to 'tabize')
-rwxr-xr-x | tabize | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -0,0 +1,30 @@ +#!/bin/sh +# Input: space-separated +column -t \ +| sed 's/ */&| /g' \ +| tac | awk 'BEGIN { + s=""; + line=""; +} +{ + if (line) print line; + if (s == "") { + split($0, chars, ""); + for (i=1; i<=length(chars); i++) { + if (chars[i] == "|") + s=s "+"; + else + s=s "-"; + } + } else { + while (length(s) < length($0)) { + s = s "-"; + } + } + line = $0; +} +END { + print s; + s=""; + print line; +}' | tac |