summaryrefslogtreecommitdiff
path: root/tabize
blob: 467581a6976fc025fdc95ce5b7f92fa4bb76d5c9 (plain)
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
#!/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