Skip to content

Instantly share code, notes, and snippets.

@youpy
Last active November 6, 2017 00:44
Show Gist options
  • Save youpy/8120784 to your computer and use it in GitHub Desktop.
Save youpy/8120784 to your computer and use it in GitHub Desktop.
#!/bin/bash
# src: http://taka.no32.tk/diary/20050826.html
set -e
KEY=`echo $@ | nkf -w -w80 | sed 's/ /+/g'`
URI="https://eow.alc.co.jp/search?q=$KEY"
CONTENT=`curl -s -e='http://eow.alc.co.jp/' \
-A 'Mozilla/5.0' "$URI" | \
sed -ne '/<ul/,/<\/ul>/p' | grep -v '<li[^>]*><a ' | grep -v '"tango"' | w3m -dump -T 'text/html'`
if [ -n "$(echo "$CONTENT" | grep "$@$")" ]; then
echo $@ >> ~/.eng-list # 履歴を保存(不要なら削除).
echo "$CONTENT" | less -c
else
echo "Not Found" >&2
exit 1
fi
#!/bin/bash
# requires gsort and tw
#
# $ brew install coreutils
# $ gem install tw
cat ~/.eng-list \
| sort \
| uniq \
| gsort --random-sort \
| head -1 \
| xargs -I{} ej {} \
| tr '\n' ' ' \
| sed 's/ \{2,\}/ /g' \
| sed 's/{[^}]*}//g' \
| cut -c -140 \
| tw --pipe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment