Usando o perl
' Text::ASCIITable
module (também suporta células de várias linhas):
print_table() {
perl -MText::ASCIITable -e '
$t = Text::ASCIITable->new({drawRowLine => 1});
while (defined($c = shift @ARGV) and $c ne "--") {
push @header, $c;
$cols++
}
$t->setCols(@header);
$rows = @ARGV / $cols;
for ($i = 0; $i < $rows; $i++) {
for ($j = 0; $j < $cols; $j++) {
$cell[$i][$j] = $ARGV[$j * $rows + $i]
}
}
$t->addRow(\@cell);
print $t' -- "$@"
}
print_table Domain 'Without WWW' 'With WWW' -- \
"$@" "${WOUT_WWW[@]}" "${WITH_WWW[@]}"
Onde as matrizes WOUT_WWW
e WITH_WWW
foram construídas como:
for domain do
WOUT_WWW+=("$(dig +short "$domain")")
WITH_WWW+=("$(dig +short "www.$domain")")
done
O que dá:
.---------------------------------------------------------------------.
| Domain | Without WWW | With WWW |
+-------------------+----------------+--------------------------------+
| google.com | 216.58.208.142 | 74.125.206.147 |
| | | 74.125.206.104 |
| | | 74.125.206.106 |
| | | 74.125.206.105 |
| | | 74.125.206.103 |
| | | 74.125.206.99 |
+-------------------+----------------+--------------------------------+
| stackexchange.com | 151.101.65.69 | stackexchange.com. |
| | 151.101.1.69 | 151.101.1.69 |
| | 151.101.193.69 | 151.101.193.69 |
| | 151.101.129.69 | 151.101.129.69 |
| | | 151.101.65.69 |
+-------------------+----------------+--------------------------------+
| linux.com | 151.101.193.5 | n.ssl.fastly.net. |
| | 151.101.65.5 | prod.n.ssl.us-eu.fastlylb.net. |
| | 151.101.1.5 | 151.101.61.5 |
| | 151.101.129.5 | |
'-------------------+----------------+--------------------------------'