From: Michael Welle <mwe012008@gmx.net>
To: emacs-orgmode@gnu.org
Subject: Re: How to get a table into a variable in a shell code block?
Date: Sun, 04 Apr 2021 07:26:53 +0200 [thread overview]
Message-ID: <878s5yr55u.fsf@luisa.c0t0d0s0.de> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2104031456420.101947@shell3.miskatonic.org> (William Denton's message of "Sat, 3 Apr 2021 14:57:54 -0400 (EDT)")
Hello,
William Denton <wtd@pobox.com> writes:
> On 3 April 2021, Greg Minshall wrote:
>
>> #+begin_src shell :results output :var n=numbers
>> echo ${n[1]}
>> #+end_src
>
> Aha, it's in an array but I didn't see it! Thanks. Org was doing it magic but
> I got confused by bash.
interestingly I asked a similar question in #org-mode yesterday. I came
up with this approach:
* table test
** user data
#+name: userdata
| uid | name | foo | bar |
| a2s | a2 | afoo | abar |
| b2s | b2 | bfoo | bbar |
| c2s | c2 | c foo | cbar |
** code
#+begin_src sh :var userdata=userdata :separator , :results raw
echo "$userdata" | while read line ; do
IFS=','
echo "$line" | while read u n f b ; do
echo "u: $u n: $n f: $f b: $b"
done
done
#+end_src
This looks a bit clumsy, but should also work with shell that doesn't
support (2D) array type variables.
Regards
hmw
next prev parent reply other threads:[~2021-04-04 5:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-03 18:14 How to get a table into a variable in a shell code block? William Denton
2021-04-03 18:45 ` Greg Minshall
2021-04-03 18:57 ` William Denton
2021-04-04 5:26 ` Michael Welle [this message]
2021-04-03 19:01 ` Juan Manuel Macías
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=878s5yr55u.fsf@luisa.c0t0d0s0.de \
--to=mwe012008@gmx.net \
--cc=emacs-orgmode@gnu.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).