From f368c89fff2a8d03c0285876bb43d7a645cb5f3a Mon Sep 17 00:00:00 2001 From: toochill Date: Fri, 11 Aug 2023 03:49:43 +0700 Subject: [PATCH] New: udct.sh --- README.md | 5 +++++ udct.sh | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 README.md create mode 100755 udct.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..f26f0ee --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# scripts + +|Script|Description|Dependencies| +|-|-|-| +|[udct.sh](udct.sh)|Query a term at https://urbandictionary.com from commnd line|[jq](https://stedolan.github.io/jq)| diff --git a/udct.sh b/udct.sh new file mode 100755 index 0000000..15887fb --- /dev/null +++ b/udct.sh @@ -0,0 +1,13 @@ +#!/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