You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Subscribe to learn Go with me!](https://bitfieldconsulting.com/subscribe)
12
14
13
15
# What is `script`?
14
16
@@ -21,41 +23,11 @@ Shell scripts often compose a sequence of operations on a stream of data (a _pip
21
23
> *This is one absolutely superb API design. Taking inspiration from shell pipes and turning it into a Go library with syntax this clean is really impressive.*\
Read more: [Scripting with Go](https://bitfieldconsulting.com/golang/scripting)
25
-
26
-
# Quick start: Unix equivalents
27
-
28
-
If you're already familiar with shell scripting and the Unix toolset, here is a rough guide to the equivalent `script` operation for each listed Unix command.
26
+
# Quick start
29
27
30
-
| Unix / shell |`script` equivalent |
31
-
| ------------------ | ------------------- |
32
-
| (any program name) |[`Exec`](https://pkg.go.dev/github.com/bitfield/script#Exec)|
Read my tutorial: [Scripting with Go](https://bitfieldconsulting.com/golang/scripting)
57
29
58
-
# Some examples
30
+
# Examples
59
31
60
32
Let's see some simple examples. Suppose you want to read the contents of a file as a string:
61
33
@@ -259,6 +231,38 @@ Let's try it out with some [sample data](testdata/access.log):
259
231
1 90.53.111.17
260
232
```
261
233
234
+
# Unix equivalents
235
+
236
+
If you're already familiar with shell scripting and the Unix toolset, here is a rough guide to the equivalent `script` operation for each listed Unix command.
237
+
238
+
| Unix / shell |`script` equivalent |
239
+
| ------------------ | ------------------- |
240
+
| (any program name) |[`Exec`](https://pkg.go.dev/github.com/bitfield/script#Exec)|
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`:
@@ -399,9 +403,9 @@ See the [contributor's guide](CONTRIBUTING.md) for some helpful tips if you'd li
399
403
400
404
# Links
401
405
406
+
-[Learn Go with me](https://bitfieldconsulting.com/subscribe)
402
407
-[Scripting with Go](https://bitfieldconsulting.com/posts/scripting)
0 commit comments