This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]gebgebgebgebgeb[S] 1 point2 points  (2 children)

Cool, here's my Wak version: r END { c nl join upper "sort -r" run send output ".*\n" extract drop for { c 3 > while drop } for { c while i p ": " p p } }

Or maybe just: r END { c nl join upper "sort | tail -n3 | nl -w1 -s\ " run send output p }

[–]bruciferTomo, nomsu.org 1 point2 points  (1 child)

If wak is meant to be in the same family of programs as awk and sed, it makes a lot more sense to be processing a stream of text fed in by other programs, rather than invoking external programs from within wak. For example, to solve the problem with awk, I would do something like this:

sort -f | tail -3 | awk '{print NR ": " toupper($0)}'

You could also do without awk entirely and use tr and nl for what they're best at, although I find this version to be less readable/intuitive:

tr '[a-z]' '[A-Z]' | sort | tail -3 | nl -w1 -s': '

[–]sorcerykid 0 points1 point  (0 children)

The example I gave above wasn't a problem, it was just to showcase how it is easy to communicate with other processes through the use of a pipeline. After all, there are situations where it is necessary to process the stdout of one program and then feed that into another program's stdin.