emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Re: [babel] How to kill two birds with one stone?


From: Eric Schulte
Subject: Re: [Orgmode] Re: [babel] How to kill two birds with one stone?
Date: Fri, 25 Feb 2011 17:24:49 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> * List all files in dir (version of Seb)
>
> Just to show, this code prints a semi-colon after every filename.
>
> #+srcname: graph-files-seb2
> #+begin_src sh :results vector :var dir=graph-dir
>   find $dir -type f -print |\
>   while read -r name
>   do
>       echo "\"${name##*/}\";"
>   done
> #+end_src
>
> #+results: graph-files-seb2
> | dan   |          |
> | eric  |          |
> | other |          |
> | "seb  | vauban"; |
>
> In most cases, these have been eaten as well...
>
> Is it possible to circumvent this problem, and get my filenames (even those
> with spaces in them) in one column?
>

Hi Seb,

My first idea was to use the ":results list" header argument, to return
a simple list (rather than a table in which the last element has two
columns)

#+begin_src sh :results list
  echo "eric schulte"
  echo "dan davison"
  echo "seb vauban"
#+end_src

#+results:
- ("eric" "schulte")
- ("dan" "davison")
- ("seb" "vauban")

But that didn't work out quite as well as expected.  Perhaps list
results should be made "smarter" by concatenating list elements that
happen to be lists themselves into strings...

I then tried the following, which should work, enabling you to split the
raw results on newline in subsequent code blocks.  Note this approach
will also preserve things like ";"'s which may have been eaten by org
table import.

#+begin_src sh :results scalar
  echo "eric schulte"
  echo "dan davison"
  echo "seb vauban"
#+end_src

#+results:
: eric schulte
: dan davison
: seb vauban

Hope this helps -- Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]