我在Org-Babel中有一個小代碼塊,它應該取決於某些參數。我用awk寫了我的代碼,但是我沒有成功使用我的代碼中的參數。將變量傳遞給組織模式下的awk代碼塊
小(不工作),例如:
#+begin_src awk :var test="value" :results output
BEGIN { print "Test is "test }
#+end_src
我的參數被稱爲測試,它的值是...價值。結果如下:
#+results:
: Test is
變量測試似乎沒有,儘管:var test="value"
試圖比awk的其他語言然而,當被定義,它似乎確定(如SH的蟒蛇。):
#+begin_src python :var test="value" :results output
print "Test is %s"%test
#+end_src
#+results:
: Test is value
#+begin_src sh :var test="value" :results output
echo "Test is "$test
#+end_src
#+results:
: Test is value
我使用的是組織結構7.8.02。任何想法?謝謝!
只是猜測在這裏,你試過$測試嗎? – fredtantini
不錯的嘗試!不,我沒有。但是這也行不通 –
Aww ...快速瀏覽一下[ob-awk.el](http://orgmode.org/cgit.cgi/org-mode.git/plain/lisp/ob-awk.el)當搜索時:var引導我到這...('(replace-regexp-in-string ...(格式「$%s」...)...)')。是'#+ begin_src sh:var test =「value」:result output'然後是'awk'{BEGIN {print「Test是$ test}}''好嗎? (雖然不是真正的解決方案,但是... – fredtantini