Skip to content

Instantly share code, notes, and snippets.

@jkomyno
Created September 30, 2016 06:43
Show Gist options
  • Save jkomyno/dfc9875df1977d7ddfc21347010e6c1b to your computer and use it in GitHub Desktop.
Save jkomyno/dfc9875df1977d7ddfc21347010e6c1b to your computer and use it in GitHub Desktop.
Sometimes awk >>> python and Co
#!/bin/bash
df -h $1 | awk '
BEGIN { ORS = ""; print "[" }
/Filesystem/ {next}
{ printf "%s{\"fs\": \"%s\", \"size\": \"%s\", \"used\": \"%s\", \"available\": \"%s\"}",
separator, $1, $2, $3, $4
separator = ", "
}
END { print "]" }
' > disk.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment