scripts/udct.sh

14 lines
360 B
Bash
Executable File

#!/bin/sh
if [ -z "$@" ]; then >&2 echo "Usage: $0 word"; exit 1; fi
if [ -z "`which jq`" ]; then
exec >&2
echo "$0: require jq"
echo "$0: check https://stedolan.github.io/jq"
fi
curl -Ls https://api.urbandictionary.com/v0/define?term="$1"\
| jq '.list[0].definition'\
| awk '{ gsub(/("|\[|\]|\\r)/, ""); gsub(/\\n/, "\n"); print }'\
| fmt -w 80