lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, Mar 5, 2011 at 11:29 AM, Jeff Pohlmeyer
<yetanothergeek@gmail.com> wrote:
> Using Lua in a pipe like that feels a little awkward (no pun intended.)

As an admirer of AWK I would naturally sneak that kind of
functionality into Penlight...

If we have the following script on the path:

#!/usr/bin/env lua
require 'pl.data'.filter(arg[1])

and given that executing ps gives me this:

  PID TTY          TIME CMD
 1664 pts/0    00:00:00 bash
 1815 pts/0    00:01:02 SciTE
 1833 pts/0    00:00:07 SciTE
 2040 pts/0    00:00:00 ps

then

$ ps | lf 'PID where CMD=="SciTE"'
1815
1833

New with this PL version is the ability to say $n etc. Note that the
AWK habit of auto-conversion happens (on a per-column basis)

$ ls -l | lf '$5/1024 where $5 > 1000'
1.0185546875
5.484375
3.3056640625
13.3779296875
4

Nota bene: it only _looks_ like SQL, these are actually Lua expressions.

steve d.