[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] org babel table header sent to awk code block
From: |
Eric S Fraga |
Subject: |
Re: [O] org babel table header sent to awk code block |
Date: |
Fri, 17 Feb 2017 13:08:52 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
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
signature.asc
Description: PGP signature