Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/benhoyt/prig
- Owner: benhoyt
- License: mit
- Created: 2022-02-07T19:42:19.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-30T00:43:28.000Z (over 2 years ago)
- Last Synced: 2024-10-15T23:54:54.087Z (28 days ago)
- Language: Go
- Homepage:
- Size: 54.7 KB
- Stars: 64
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
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))'