Below you will find pages that utilize the taxonomy term “unix”
Posts
Pipelines and your Unix toolbox
Unix commands are great for manipulating data and files. They get even better when used in shell pipelines. The following are a few of my go-tos – I’ll list the commands with an example or two. While many of the commands can be used standalone, I’ll provide examples that assume the input is piped in because that’s how you’d used these commands in a pipeline. Lastly, most of these commands are pretty simple and that is by design – the Unix philosophy focuses of simple, modular code, which can be composed to perform more complex operations.
Posts
Go and Unix files
I ran into an odd Unix filename issue while writing Go code the other day.
Here’s a simplified example:
Let’s read a json file and unmarshall its contents into a struct in go. First, let’s set an environment variable with our file name to avoid hardcoded constants in our program.
export MY_FILE="/Users/dancorin/Desktop/test.json " Now, let’s read the file into our struct:
package main import ( "encoding/json" "fmt" "io/ioutil" "os" ) // Stuff struct holds the json contents type Stuff struct { Test string `json:"test"` } func main() { stuff := Stuff{} place := os.