An awk-like language that uses slope for scripting (and execution)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sloum 77466a02e0 Adds help and fixes passing a script via the --script flag 4 weeks ago Initial commit 1 month ago
slawk Adds help and fixes passing a script via the --script flag 4 weeks ago


This is a first attempt at writing an awk-like text processing system in slope, that then uses slope within the match blocks.

So, a slawk file will look something like this:

"^\d+" {
    ; slope code goes here
    ; Useful variables here:
    ;       `ln` - the current line as a string
    ;   `fields` - the current fields as a list of strings
    ; `line-num` - the current line number
    ; Any slope code can be used. Anything between `{` and `}` will
    ; get wrapped up in a lambda and executed with the given ln/fields
    ; when the regex (in double quotes that come before the openeing `{`)
    ; matches the line

Command line execution can work a few ways (this is still in flux). The first is to give a string with the script and then the file. They must be in that order. There can only be one file and one script (at present).

slawk '"[bB]utts" { (display line-num ". Nice!\n") }' intest.txt

You could also change the field separator. It needs to come before the script and the file:

slawk --FS=";" '"[bB]utts" { (display line-num ". Nice!\n") }' test.txt

Or you can pass the script as a file:

slawk --script=~/my-script.slawk test.txt


This is very much a work in progress. Features, performance, etc. are all take what you can get at this point. Expect things to shift (if I keep working on it).