[pmwiki-users] FW: cookbook "ShellTools" (was: Include specific lines of text on a page)

Hans design5 at softflow.co.uk
Mon Jan 21 05:39:16 CST 2008


Sunday, January 20, 2008, 10:21:57 PM, Peter & Melodye Bowers wrote:

> How would you differentiate between these 2 calls which do very different
> things:

> Tail -n 20 file1 file2 | grep 'mytext'

> Grep 'mytext' file1 file2 | tail -n 5

I am aware of the difference, and can see the power in combining
various markup expression, nesting them etc.
But I am not at all clear how this can be done efficiently when
processing multiple pages.
Therefor my first reaction was to create just one tool, and factor
into it some options which may ideally be better as separate markup
expressions.
I need to sit down and think on it.


> Another option would be to implement something like this:

> {(shell tail -n 20 file1 file2 | grep "mytext")}
> {(shell grep "mytext" file1 file2 | tail -n 5)}

This looks daunting, and I confess I do not like the nomenclature.
Even "Shell Tools" seems to be wrong in PmWiki context. We do not have a
shell. And there are probably many users not familiar with unix/linux
terminology.

I don't quite see the point of trying to translate Linux shell tools
with their unchanged syntax. I think it is better to use syntax
which is commonly in use in PmWiki, and use descriptive naming if
possible.


> Anyway, obviously (tail...) is the simplest possible tool to implement
> (except head) but it does show the nesting and stuff...

Why create separate 'head' and 'tail' markup expressions? Why not just
one, if one is needed at all?

>> Looking again at the (:include ..:) options I realise that in the
>> grep.php script I lost the ability to source text not just from whole
>> pages, but from specified sections. I think it would be useful to gain
>> that too.

> This would be a very powerful feature - I have no idea how it's implemented,
> but I've been reading enough of your stuff in the forum to know that you are
> very experienced in that field.  And this may be one of the places where it
> makes a lot of sense to deviate from simple text-file-processing and do
> something wiki-specific.

This could be part of the 'head and tail' tool or function.


> If I wanted to find the first n lines or the last n lines there could be an
> insertion of a (head...) or (tail...) at any level outside the (grep...).  I
> don't know if I'm adequately showing how powerful these simple tools can be
> when given the flexibility to order them and combine them in a freeform
> way...

yes you do. I just don't know an efficient way for multiple page
processing having separate markup expressions.

~Hans






More information about the pmwiki-users mailing list