summaryrefslogtreecommitdiff
path: root/tabize
diff options
context:
space:
mode:
Diffstat (limited to 'tabize')
-rwxr-xr-xtabize30
1 files changed, 30 insertions, 0 deletions
diff --git a/tabize b/tabize
new file mode 100755
index 0000000..467581a
--- /dev/null
+++ b/tabize
@@ -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