Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/benhoyt/prig

Prig is for Processing Records In Go. Like AWK, but snobbish.
https://github.com/benhoyt/prig

Last synced: 16 days ago
JSON representation

Prig is for Processing Records In Go. Like AWK, but snobbish.

Awesome Lists containing this project

README

        

# Prig: the snobbish AWK

Prig is for **P**rocessing **R**ecords **I**n **G**o. It's like AWK, but snobbish (Go! static typing!). It's also faster to execute, and if you know Go, you don't need to learn AWK.

You can also read my article on [**why and how I wrote Prig**](https://benhoyt.com/writings/prig/). The tl;dr is "no good reason, I'm a geek!" :-)

## How to use Prig

To install `prig`, make sure Go is [installed](https://go.dev/doc/install) and then type `go install github.com/benhoyt/prig@latest`. Prig itself runs the generated code using `go build`, so even once you have a `prig` executable it requires the Go compiler to be installed.

As a simple example, you can try the following script. It prints a modified version of the second field of each line of input (the full URL in this example):

```
$ cat logs.txt
GET /robots.txt HTTP/1.1
HEAD /README.md HTTP/1.1
GET /wp-admin/ HTTP/1.0

$ prig 'Println("https://example.com" + S(2))'