Skip to content

Instantly share code, notes, and snippets.

@mvisonneau
Created April 24, 2018 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvisonneau/3bb27436d1b6a4cfe36cbed5b518c9f0 to your computer and use it in GitHub Desktop.
Save mvisonneau/3bb27436d1b6a4cfe36cbed5b518c9f0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if ! [ -x "$(command -v git)" ]; then
echo 'Error: jq is not installed.' >&2
exit 1
fi
if [ -z "$1" ]; then
echo "Error: you must pass the filename as an argument"
exit 1
else
FILE=$1
fi
if [ ! -f ${FILE} ]; then
echo "Error: file ${FILE} does not exist"
exit 1
fi
# Build JSON output using JQ
jq -n --arg data "$(<${FILE})" '{"data":$data}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment