emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sébastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: Re: [babel] How to kill two birds with one stone?
Date: Fri, 25 Feb 2011 15:27:29 +0100	[thread overview]
Message-ID: <80y654nq9a.fsf@somewhere.org> (raw)
In-Reply-To: 87sjvj6oul.fsf@gmail.com

Hi Eric,

First, thanks for answering this open thread!

"Eric Schulte" wrote:
> I haven't followed this discussion very closely, but I'm not sure why it
> would be necessary to pass data through STDIN rather than through a variable
> or an external file.

I'll comment on the full problem (or solution) later on. But I'd like to share
a first problem with you.

> I took a shot at the dot graph example you proposed, the following works for
> me over a simple example directory.

I've redone (almost) the same file structure as yours, so that our results
must be similar, if not equal.

> directory to search
> #+results: graph-dir
> : graph-dir
>
> list all files in dir
> #+source: graph-files
> #+begin_src sh :results vector :var dir=graph-dir
>   find $dir -type f -exec basename {} \;
> #+end_src
>
> #+results: graph-files
> | other |
> | dan   |
> | eric  |
> | seb   |
>
> association of files with mentions
> #+source: graph-associations
> #+begin_src sh :var dir=graph-dir :var files=graph-files
>   for i in $files; do
>       for j in `grep -l -r $i $dir`;do
>           echo $i, `basename $j`
>       done
>   done
> #+end_src
>
> #+results: graph-associations
> | other | eric |
> | other | seb  |
> | dan   | eric |
> | eric  | seb  |
> | seb   | dan  |

My adapted version of your first paragraphs:

* Directory to search

#+results: graph-dir
: graph-dir

* List all files in dir (version of Eric)

#+source: graph-files
#+begin_src sh :results vector :var dir=graph-dir
  find $dir -type f -exec basename {} \;
#+end_src

#+results: graph-files
| dan   |        |
| eric  |        |
| other |        |
| seb   | vauban |

* List all files in dir (version of Seb)

My code was a bit more complex... because I need to be able to correctly take
care of filenames containing spaces inside them (I'm on Windows, I never do
such a thing, but there are well spaces on the files I wanna graph).

#+srcname: graph-files-seb
#+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-seb
| dan   |         |
| eric  |         |
| other |         |
| "seb  | vauban" |

Spaces are used as colon delimiters: they win over my double quotes.

* 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?

Best regards,
  Seb

-- 
Sébastien Vauban


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2011-02-25 14:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-04 16:00 [babel] How to kill two birds with one stone? Sébastien Vauban
2011-02-04 17:43 ` Dan Davison
2011-02-04 22:23   ` Sébastien Vauban
2011-02-06 16:51   ` Sébastien Vauban
2011-02-20  8:57     ` Eric Schulte
2011-02-25 14:27       ` Sébastien Vauban [this message]
2011-02-25 22:44         ` Nick Dokos
2011-02-25 22:55           ` Nick Dokos
2011-02-28 13:59           ` Sébastien Vauban
2011-02-26  0:24         ` Eric Schulte
2011-02-26  9:56           ` Closing #+results: with #+end declaration? Bastien
2011-02-27 20:00             ` Eric Schulte
2011-02-28 13:54               ` Sébastien Vauban
2011-03-03 11:11               ` Bastien
2011-02-28 15:16       ` [babel] How to kill two birds with one stone? Sébastien Vauban

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80y654nq9a.fsf@somewhere.org \
    --to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).