47 lines
829 B
Org Mode
47 lines
829 B
Org Mode
#+Title: a collection of examples for ob-awk tests
|
|
#+OPTIONS: ^:nil
|
|
|
|
* Simple tests
|
|
:PROPERTIES:
|
|
:ID: 9e998b2a-3581-43fe-b26d-07d3c507b86a
|
|
:END:
|
|
Run without input stream
|
|
#+begin_src awk :output silent :results silent
|
|
BEGIN {
|
|
print 42
|
|
}
|
|
#+end_src
|
|
|
|
Use a code block output as an input
|
|
#+begin_src awk :stdin genseq :results silent
|
|
{
|
|
print 42+$1
|
|
}
|
|
#+end_src
|
|
|
|
Use input file
|
|
#+name: genfile
|
|
#+begin_src awk :in-file ob-awk-test.in :results silent
|
|
$0~/[\t]*#/{
|
|
# skip comments
|
|
next
|
|
}
|
|
{
|
|
print $1*10
|
|
}
|
|
#+end_src
|
|
|
|
#+name: awk-table-input
|
|
| a | b | c |
|
|
|
|
#+begin_src awk :var a=awk-table-input
|
|
BEGIN{ print a; }
|
|
#+end_src
|
|
|
|
* Input data generators
|
|
A code block to generate input stream
|
|
#+name: genseq
|
|
#+begin_src emacs-lisp :results silent
|
|
(print "1")
|
|
#+end_src
|