From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?S=C3=A9bastien_Vauban?= Subject: Re: [babel] How to kill two birds with one stone? Date: Fri, 25 Feb 2011 15:27:29 +0100 Message-ID: <80y654nq9a.fsf@somewhere.org> References: <808vxv23j2.fsf@missioncriticalit.com> <80mxm9yulk.fsf@missioncriticalit.com> <87sjvj6oul.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org 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 varia= ble > or an external file. I'll comment on the full problem (or solution) later on. But I'd like to sh= are 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=3Dgraph-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=3Dgraph-dir :var files=3Dgraph-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=3Dgraph-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 ta= ke 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=3Dgraph-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=3Dgraph-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 --=20 S=C3=A9bastien 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