0

It's been some time since posting to the forum. I've been trying to find a solution in the bash or zsh programming language that would allow me to cat tables to files that later I could update with textual strings including info on time and dates, to keep track of tasks that I'm performing. In doing this I started looking into groff's tbl, which generates tables. I love groff but one of the issues I have with it is that it prints seven empty lines before the table and 53 empty lines after. This is the table.me file:

.TS
allbox;
c s s s 
c c c c.
work hours
             
.TE

and my command for displaying this to the terminal is:

tbl Documents/tempdir/tmp18=.md| groff -me -T ascii

I'm running these commands inside a zsh shell on kitty terminal on a os x Majove 10.14.6

This is the output:








+--------------+
| work hours   |
+--+---+---+---+
|  |   |   |   |
+--+---+---+---+























































Why so much whitespace? why so many newlines? I tried pruning these lines with

tbl Documents/tempdir/tmp18=.md| groff -me -T ascii | sed -e 's/*[  ]*//'

Does groff always consistently produce so many newlines? I've experimented using head and tail to get the table isolated but my main problem with this method is while changing the table I also have to change the values of head and tail. Is there a way to get groff to print to stdout without this proceeding and post-ceeding empty lines?

2 Answers2

1

Groff fills the page. The default page is 11 inches, so that is quite a number of white space. There are a number of possibilities:

  • set the page length to a smaller value:
.pl 10v
  • remove all empty lines:
tbl t.tbl | groff -mwww -T ascii | sed '/^\s*$/d'
  • remove them from the end of the file:
tbl t.tbl | groff -mwww -T ascii | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}'
Ljm Dullaart
  • 4,273
  • 2
  • 14
  • 31
0

I don't think I have groff installed, (I'm in Cygwin atm unfortunately) but...

tbl Documents/tempdir/tmp18=.md | groff -me -T ascii | tr -s ' ' | tr -d '\n'

If I didn't know better, reading this site would make me think I was the only person alive who still remembers tr; and even moreso ed.

petrus4
  • 616
  • 4
  • 7