Org mode: Table Data ⇒ Code ⇒ Results

Quick example of how to use table data in a source block with Bash:

#+name: data
| 1 |
| 2 |
| 3 |
| 4 |

#+name: code
#+begin_src sh :var arg=data :results output
printf "%s\n" "${arg[@]}"
#+end_src

#+RESULTS: code
#+begin_EXAMPLE
1
2
3
4
#+end_EXAMPLE

Here is how the block expands using org-babel-expand-src-block:

unset arg
declare -a arg=( '1' '2' '3' '4' )
printf "%s\n" "${arg[@]}"

Leave a Reply

Your email address will not be published. Required fields are marked *