emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <e.fraga@ucl.ac.uk>
To: emacs-orgmode@gnu.org
Subject: Re: org babel table header sent to awk code block
Date: Fri, 17 Feb 2017 13:08:52 +0000	[thread overview]
Message-ID: <87shndc6cb.fsf@ucl.ac.uk> (raw)
In-Reply-To: <48db0e51591f4ff180507a99ea72ad5a@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> (Roland Everaert's message of "Fri, 17 Feb 2017 12:33:39 +0000")

[-- Attachment #1: Type: text/plain, Size: 851 bytes --]

On Friday, 17 Feb 2017 at 12:33, Roland Everaert wrote:
> Hi,
>
> I am trying to filter a table using the following awk code block.

I think your problem is an error in the awk script; specifically, the
match is outputting all lines because you need to have the { on the same
line as the match expression.  Try this:

#+BEGIN_SRC awk :stdin list-example :var fstcol=1 :var seccol=3 :results output org
  BEGIN {
  print "|Host|Result"
  print "|-"
  }
  $seccol ~ /[0-9]{1,3}(\.[0-9]\{1,3\}){3}/ {
  print "|"$fstcol"|"$seccol
  }
#+END_SRC

You may have noticed that the second line (which had an empty third
column so should not have matched) was also being output when it
shouldn't have.

In any case, the above works for me.

HTH,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.4-242-g2c27b8

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

       reply	other threads:[~2017-02-17 14:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <48db0e51591f4ff180507a99ea72ad5a@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-02-17 13:08 ` Eric S Fraga [this message]
2017-02-17 15:00   ` org babel table header sent to awk code block Roland Everaert
2017-02-17 12:33 Roland Everaert

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=87shndc6cb.fsf@ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --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).