I have a code chunk in my document that I want to use as a list of patterns to search for with grep.
If I were just writing a script without org-babel, I could write.
a="ar
er
ir
or
ur"
printf "Four\nscore\nand\nseven\nyears\nago" | grep -F "$a"
And the results would be
Four
score
years
But instead of $a
, I want to use the output of an earlier code block.
#+NAME: vowel_r
#+BEGIN_SRC sh :shebang "#!/bin/bash" :results verbatim
a="ar
er
ir
or
ur"
echo "$a"
#+END_SRC
#+RESULTS: vowel_r
: ar
: er
: ir
: or
: ur
I would have thought that this would work.
#+BEGIN_SRC sh :shebang "#!/bin/bash" :noweb yes
printf "Four\nscore\nand\nseven\nyears\nago" | grep -F "<<vowel_r()>>"
#+END_SRC
But it throws the error.
/tmp/babel-4438QgK/sh-script-4438Wst: line 8: unexpected EOF while looking for matching `"'
/tmp/babel-4438QgK/sh-script-4438Wst: line 9: syntax error: unexpected end of file
By looking at the code with C-c C-v v, it seems that noweb is treating each line of the output separately, instead of as a multi-line string.
printf "Four\nscore\nand\nseven\nyears\nago" | grep -F "ar
printf "Four\nscore\nand\nseven\nyears\nago" | grep -F "er
printf "Four\nscore\nand\nseven\nyears\nago" | grep -F "ir
printf "Four\nscore\nand\nseven\nyears\nago" | grep -F "or
printf "Four\nscore\nand\nseven\nyears\nago" | grep -F "ur
printf "Four\nscore\nand\nseven\nyears\nago" | grep -F ""
Removing the quote marks around <<vowel_r>>
just leads to a grep error.
How can I get noweb to treat the output of the earlier block as a multi-line string, instead of handling each line separately?
Thank you!