Skip to content

Commit 5b2f8f4

Browse files
authored
Add go-script to readme (#222)
1 parent 50f0076 commit 5b2f8f4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,25 @@ Let's try it out with some [sample data](testdata/access.log):
259259
1 90.53.111.17
260260
```
261261

262+
# A `script` “interpreter”
263+
264+
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`:
265+
266+
* [`go-script`](https://til.simonwillison.net/bash/go-script)
267+
268+
With `go-script`, you can run `script` one-liners directly:
269+
270+
```sh
271+
cat file.txt | ./goscript.sh -c 'script.Stdin().Column(1).Freq().First(10).Stdout()'
272+
```
273+
274+
or create `.goscript` files that you can run using a “shebang” line:
275+
276+
```sh
277+
#!/tmp/goscript.sh
278+
script.Stdin().Column(1).Freq().First(10).Stdout()
279+
```
280+
262281
# Documentation
263282

264283
See [pkg.go.dev](https://pkg.go.dev/github.com/bitfield/script) for the full documentation, or read on for a summary.

0 commit comments

Comments
 (0)