From 5b2f8f4755fe1ea9d89b1e433c0e45e0253cdd12 Mon Sep 17 00:00:00 2001 From: John Arundel Date: Mon, 13 Jan 2025 12:56:53 +0000 Subject: [PATCH] Add go-script to readme (#222) --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 2e947fc..0510040 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,25 @@ Let's try it out with some [sample data](testdata/access.log): 1 90.53.111.17 ``` +# A `script` “interpreter” + +One of the nice things about shell scripts is that there's no build process: the script file itself is the “executable” (in fact, it's interpreted by the shell). Simon Willison (and GPT-4) contributed this elegant `script` interpreter, written in `bash`: + +* [`go-script`](https://til.simonwillison.net/bash/go-script) + +With `go-script`, you can run `script` one-liners directly: + +```sh +cat file.txt | ./goscript.sh -c 'script.Stdin().Column(1).Freq().First(10).Stdout()' +``` + +or create `.goscript` files that you can run using a “shebang” line: + +```sh +#!/tmp/goscript.sh +script.Stdin().Column(1).Freq().First(10).Stdout() +``` + # Documentation See [pkg.go.dev](https://pkg.go.dev/github.com/bitfield/script) for the full documentation, or read on for a summary.