Skip to content

Instantly share code, notes, and snippets.

@josephok
Last active December 14, 2018 07:31
Show Gist options
  • Save josephok/61a6f3a7debc5cb9dede6fa2f18f927d to your computer and use it in GitHub Desktop.
Save josephok/61a6f3a7debc5cb9dede6fa2f18f927d to your computer and use it in GitHub Desktop.
Generate a random name based on https://randomuser.me/api/
#!/usr/bin/env bash
which jq &> /dev/null
if [[ $? -ne 0 ]]
then
echo "Please install jq first, see https://stedolan.github.io/jq/"
exit 1
fi
name=$(curl -s https://randomuser.me/api/)
title=$(echo $name | jq .results[0].name | jq .title | sed 's/"//g')
first=$(echo $name | jq .results[0].name | jq .first | sed 's/"//g')
last=$(echo $name | jq .results[0].name | jq .last | sed 's/"//g')
echo "Hello ${title^}. ${first^} ${last^}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment