I'm trying to add headers to this:
#+BEGIN_SRC sh :dir ~ :results table
for n in 1 2 3 4; do
echo $n $(($n * $n))
done
#+END_SRC
Which results in:
#+RESULTS:
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
| 4 | 16 |
The output I want is:
#+RESULTS:
| N | N*N |
|---+-----|
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
| 4 | 16 |
The difficulty I'm having is injecting the second line. This does not work:
#+BEGIN_SRC sh :dir ~ :results table
echo "N N**2"
echo "|-"
for n in 1 2 3 4; do
echo $n $(($n * $n))
done
#+END_SRC
This results in:
#+RESULTS:
| N | N**2 |
| | - |
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
| 4 | 16 |
Neither can I just use a blank line, as suggested here:
#+BEGIN_SRC sh :dir ~ :results table
echo "N N**2"
echo
for n in 1 2 3 4; do
echo $n $(($n * $n))
done
#+END_SRC
As this results in:
#+RESULTS:
| N | N**2 |
| | |
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
| 4 | 16 |
Any hints greatly appreciated!
:results org drawer
rather than just:results org
then it exports as a nice table :-) – Ency