Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
awk '{
for (col=1; col<=NF; col++) {
if (max[col] < length($col))
max[col] = length($col)
arr[NR, col] = $col
}
[highlight]if (maxnf < NF)[/highlight]
[highlight]maxnf = NF[/highlight]
}
END {
for (row=1; row<=NR; row++) {
for (col=1; col<=[highlight]maxnf[/highlight]; col++)
printf "%-" max[col] "s ", arr[row,col]
print ""
}
}' file1
#!/bin/bash
#
# Table-view script
#
cat << EOF > table.tmp
.TS
center,tab (_);
l l l l r l l l l.
EOF
#
# replace with your data-producing cmd:
#
cat tbl.data | sed 's/ */_/g' >> table.tmp
#
echo ".TE" >> table.tmp
tbl table.tmp | nroff | head -n8
942 07/07/2004 08:17:00 aaaaaaaaaa 2393286 ORA-02290: check c vio
997 07/07/2004 14:21:28 aaaaaaaaaaaaaaaaaaaaaaaaaaa 43434343 Primary Violation c vio
033 07/07/2004 14:21:28 aaaaaaaaaaaaaaaaa 2933101 ORA-00001: unique c vio
891 07/08/2004 08:23:40 aaaaaaaaaaa 3093754 Primary Violation c vio
printf [b](col==5?"%":"%-")[/b] max[col] "s ", arr[row,col]
awk '{
for (col=1; col<=NF; col++) {
if (max[col] < length($col))
max[col] = length($col)
arr[NR, col] = $col
}
if (maxnf < NF)
maxnf = NF
}
END {
for (row=1; row<=NR; row++) {
for (col=1; col<=maxnf; col++) [b]{
if (col==5)
fmt="%" max[col] "s "
else if (col>5)
fmt="%s "
else
fmt="%-" max[col] "s "[/b]
printf [b]fmt[/b], arr[row,col]
[b]}[/b]
print ""
}
}' file1