Skip to content

Commit

Permalink
Add go-script to readme (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfield authored Jan 13, 2025
1 parent 50f0076 commit 5b2f8f4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5b2f8f4

Please # to comment.